Controlling A Smart Traffic Light Using Programmable Logic Controller (PLC)
Controlling A Smart Traffic Light Using Programmable Logic Controller (PLC)
net/publication/340558962
CITATIONS READS
0 8,745
1 author:
Ahmad Krikr
Newcastle University
2 PUBLICATIONS 0 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Ahmad Krikr on 10 April 2020.
1
NEWCASTLE UNIVERSITY
School of Engineering
Electrical and Electronic Engineering
I, Ahmad Redwan Krikr, confirm that this report and the work presented in it are my
own achievement.
I have read and understand the penalties associated with plagiarism.
29/08/2019
Signed: ....................................................... Date: ...............................................
Abstract
This project is about controlling a traffic light using PLC, PLC programming languages
explained, and ladder logic language chose to program the PLC. The PLC used is from Siemens
company, S7-1200 CPU 1215c. Many researches in same area discussed and reviewed to take the
benefit from it. Methodology suggested to collect data is by using inductive loop sensor to count
vehicle number using the junction and using RFID (radio frequency identification) to detect priority
cases. The system designed to control a four-way junction. Also, the system has four main control
features, first is to perform a normal cycle in case all streets forming the junction have equal
vehicles density. Second, in case of pedestrian presence, a pedestrian signal implemented to give
safe junction pass for the pedestrian. Third, in case of high vehicles density on one direction of the
signal, the green light for that direction will operate for longer time depending on vehicles number.
Last feature, in case of emergency vehicle need to pass the junction, the signal will open green light
for the emergency direction and red light for other direction, and when the priority vehicle pass the
junction, the signal will back to what it was before the emergency case.
Those features were the project aims and objectives, and all of them were achieved. The
used hardware is mentioned clearly, and the program developed is illustrated and explained. The
limitations faced are mentioned and improvement are for future work discussed.
Acknowledgment
I would like to thank my family for their continuous support, and engineering department in
Newcastle university for their care and their continuous improvement. Also, a special thanks for all
professors who suffers with teaching us different modules with keeping high quality of education,
and thanks for my supervisor Dr. Kristopher Smith for his continuous support and encouragement
and advisement.
Table of Contents
Abstract ..................................................................................................................................................
Acknowledgment ...................................................................................................................................
List of principal symbols ........................................................................................................................
List of figures .........................................................................................................................................
1 Introduction .................................................................................................................................. 1
1.1 PLC architecture .................................................................................................................... 2
1.1.1 Central processing unit (CPU) ....................................................................................... 2
1.1.2 Memory .......................................................................................................................... 2
1.1.3 Bus interface ................................................................................................................... 2
1.1.4 Inputs and outputs controller .......................................................................................... 3
1.2 PLC programming languages ................................................................................................ 3
1.2.1 Sequential function chart (SFC) ..................................................................................... 3
1.2.2 Function block diagram (FBD) ...................................................................................... 4
1.2.3 Instruction list (IL) ......................................................................................................... 4
1.2.4 Structured text (ST) ........................................................................................................ 5
1.2.5 Ladder logic (LAD) ........................................................................................................ 5
1.3 Traffic lights history and development .................................................................................. 6
2 Problem description and project aims .......................................................................................... 6
3 Previous work ............................................................................................................................... 7
4 Methodology .............................................................................................................................. 13
4.1 Data collection ..................................................................................................................... 13
4.2 Data processing.................................................................................................................... 15
5 System simulation(prototype) .................................................................................................... 16
5.1 System description ............................................................................................................... 16
5.1.1 Normal cycle ................................................................................................................ 18
5.1.2 Pedestrian case ............................................................................................................. 19
5.1.3 High density case ......................................................................................................... 19
5.1.4 priority case .................................................................................................................. 20
5.2 Hardware .................................................................................................................................. 22
5.3 Software and programming ................................................................................................. 25
5.3.1 Normal cycle program .................................................................................................. 25
5.3.2 Pedestrian program ....................................................................................................... 27
5.3.3 High density program ................................................................................................... 30
5.3.4 Priority program ........................................................................................................... 32
5.4 Limitation ............................................................................................................................ 34
6 Improvement area for future work ............................................................................................. 35
6.3 Controlling traffic by SCADA system ................................................................................ 35
6.4 Continues traffic tracking by GPS system ........................................................................... 35
7 Conclusion .................................................................................................................................. 36
7 References ....................................................................................................................................... 37
8 Appendices ...................................................................................................................................... 39
8.1 junction designed photo ........................................................................................................... 39
8.2 system designed photo ............................................................................................................. 41
8.3 PLC and signal module photo .................................................................................................. 42
8.4 Resistors connected in series .................................................................................................... 43
8.5 overall program (Main OB, P1, P2, P3, P4 and yellow flash) ................................................. 44
List of principal symbols
1
1.1 PLC architecture
Figure 1 above, shows the typical architecture for PLC. A typical PLC has three main block,
CPU, memory and inputs/outputs controller [2]. These blocks are connected to each other through a
bus system, the bus system is connected to external network controller as well [2]. To illustrate how
a PLC is operating, the following section is describing the main blocks.
1.1.1 Central processing unit (CPU)
Usually in PLC, the CPU is 8- or 16-bit microprocessor, its processing power less than PCs
and SCADA system processing power, the memory used is small and most of it will be external [2].
1.1.2 Memory
Like any computer, the CPU will process the data using a memory, there is to type of
memory, random access memory (RAM) and programmable read only memory (PROM) [2].
RAM has the largest portion of the total memory, it is used for user program space and
system data storage, and it will be erased when the PLC switched off and its allowed the CPU to
read from and write any as many it is required. While, PROM is used to store the main system
operation that needed to run the PLC, and it saves the data even if the power switched off, the CPU
can only read from it [2].
1.1.3 Bus interface
Bus is a parallel wires that meant to deliver the digital signals from/to specified destination,
most system has three types of bus, (I) Data bus: this bus is to carry the data that the CPU sending
2
out the processing operation, usually its 8- or 16 bit bus [2]. (II) Address bus: this bus is used to
communicate with a specific location in the memory [2]. (III) Control bus: this bus is used to carry
the controlling signals to do an action [2].
1.1.4 Inputs and outputs controller
Input and output controller are the interface between the PLC and the processes or operations
need to be controlled. Usually, the inputs are a sensors and the output will be connected to an
actuators
1.2 PLC programming languages
There are different languages to program a PLC, some of them are graphical based programing
languages and the other based on high level computer language. Below, there is briefly explained
most using programing languages.
1.2.1 Sequential function chart (SFC)
It is called Grafcet language as well [1]. This language is based on graphical method, its
purpose to break down a complex program to smaller blocks, and describe the program as a
flowchart, it’s possible to design the program as sequential and parallel processes [3]. Process that
need step by step control is suitable for SFC language, for example, controlling a washing machine.
Figure 2 below, shows an example of SFC program
Figure 2 above, showing a general example of step by step control in SFC language, after the
operation is started, if condition 1 is true the output will be energized, then the next step is when
condition 2 is true and so on till the operation is stopped.
3
1.2.2 Function block diagram (FBD)
This language is a graphical language and it is close to ladder logic language, the
programming blocks are separated by networks. Figure 3 below, shows an example of FBD
language.
In figure 3 above, if VarAnd1 and VarAnd2 is true at the same time, the output of the AND
block will be true then one count will be considered by counter_1, when counter_1 value reach 1000
then VarOut will be true. This programming language is not suitable for complex program due to the
high number of required blocks to achieved the process goals, but it is efficient language for simple
operations [1] [3].
1.2.3 Instruction list (IL)
It’s a text-based language, IL is universal usable language, its employed as intermediate
language between other textual languages and graphical languages and its line oriented language in
which the command for the PLC is described in one line. [3]. Figure 4 below shows an example for
IL language.
In figure 4 above, when the input A and not the input B is true, the output C will be
energized. Its noticeable that implementing the logic in IL language in more direct than using the
graphical languages, in figure 4 above, the example used only (ANDN) instruction to implement the
logic and not, while in FBD it will be a graphical block. This language is more suitable for complex
program since it is showing the instructions line by line [3].
4
1.2.4 Structured text (ST)
It’s a high level computer language, its offer a large number of statement to describe a
complex functionality in compressed way also it’s a clear instructions in statement blocks and a
powerful tool to control a command flow [3]. It consist of different statement separated by
semicolons (;), this mean that different statements can be written in single line unlike the IL
language, ST language is similar to C and PASCAL language in the PC languages [3]. The powerful
lopping commands like (WHILE, FOR, CASE) can check a huge number of conditions in single
loop program, while if graphical language used to check the same amount of conditions it will
required a separate line to check each condition so it will need much more effort to achieve the same
output. Figure 5 below shows an example of using IF and ELSIF in ST language, its similar to
PASCAL language in this example.
In figure 6 above, when Var1 and Var2 and (Var3 or Var4) is true, VarOut will be true. In
general, ladder logic is similar an electrical circuit, when the input of switch or block is energized,
the output will be energized, most used switches in ladder logic in normally open and normally
closed switches, which they act opposed to each other, and there are conditional switches, like grater
5
then and less than and equal to, if the condition is true, the output will be energized as well. Also,
ladder logic has a programmed block like timers and counters, which can be used to achieve the
required logic. This project used ladder logic to program the PLC to control a traffic light, the
program developed is illustrated and described in section 5.2.
1.3 Traffic lights history and development
In 1868, first traffic light was fixed near to the house of parliament in London. It was to control
the horses with pedestrian movement through the junction. In the daytime it was using semaphore
arms controlled by police officer, and in the nighttime, it used gaslit for green and red light
controlled by police officer also. Then with time, first electric traffic light was used in 1914. With
the invention of computers in 1960s, the traffic lights start to be controlled by computers using
installed software [4]. Nowadays, traffic light has improved a lot, it can sense the presence of
vehicles using sensors and change the lights depending on that. With technology raising, the
efficiency of traffic light is increasing [4].
6
3 Previous work
To achieve the project aims, some of the previous projects and researches in the same field has
been reviewed and considered. In [5], the paper is about controlling the traffic using PLC and
SCADA system, their method is based on counting the vehicles number and vehicles weight in each
lane of the junction in order to control the traffic. The design can be implemented on city traffic and
highways [5]. They consider that the traffic light fails to control the traffic effectively if a lane got
more traffic than other lanes. So, their design suggests using different lanes for different vehicles
based on their weigh (buses, trucks, etc.). Using weigh sensors, the PLC will give diversion to the
vehicles [5]. Figure 7 below, shows the method used to assign the lanes.
Also in [5], for congestion control, they used two counters, one at the road start(up counter)
and the other at road end(down counter). Figure 8 below, shows how the method work.
This method will reduce the congestion and accidents sense heavy and light vehicles will be
separated in different lanes [5].
7
In [6], they used a video camera to monitor the traffic in one intersection in Penang Island in
Malaysia, and by using an associative memory they can determine three road cases (crowded,
normal and empty street). The program can determine all street cases in different weather depending
on the video cameras, each street form the intersection has one camera [6]. The system input is a
sequence of images, the system has two main components, image analyzer and an associative
memory, the image analyzer consist of two phases, training and recognition phase [6]. The images
came from the cameras will be converted to binary by using classic filter to determine the street
case, these images will be considered in the training phase then it will be saved in the associative
memory to be used later in the recognition phase [6]. They used 2571 photos taken in the night and
2734 photo taken in the day to simulate their system, they found that the system has an economical
value by reducing the fuel used by the vehicles who waiting the green light unnecessarily [6].
In [7], they designed a traffic control system using a PLC as a controller and different set of
sensors as an input for the system, the system is controlling a traffic light depending on number of
vehicles. They present some statistics about some cities and countries using a traffic control system,
like in New York, 7660 intersection out of 12400 are controlled by one central computer, and in
Toronto, 83% of the intersections are controlled by main traffic signal system (MTSS) and in
Sidney, 3400 signal are controlled by a system called Sidney Co-ordinate adaptive traffic system
(SCATS), and by 2010, SCATS been used to control 33200 signal in 144 different cities in 24
different countries [7]. These statistics mentioned to prove that, controlling traffic systems is very
active field to design and improve. In [7], they used Siemens PLC CPU 313c to control the traffic
light with human machine interface (HMI), Weintek HMI allow to view the process controlled
graphically to be monitored. They suggest different sensors to sense the traffic flow, like inductive
sensors, it make an inductive loop on the each lane, each loop has frequency between 10 KHz and
200 KHz, as any vehicle pass the loop, the inductivity will decrease, by this method, the sensor can
count number of vehicles and confirm the vehicles presence and calculate the vehicles weight [7].
Figure 9 below, shows how inductive sensors are installed.
8
Another sensor could be used, is optical sensor shown figure 10 below, or video camera
shown in figure 11 below, or acoustic sensor shown in figure 12 below.
All these sensors above, can count number of vehicles accurately [7].
9
In [8], they used PLC to control a traffic light. They considered in the design the emergency
cases, where if an emergency accrues, the priority vehicle will pass first, they used a software called
MCGS to animate and simulate the system. Figure 13 below, show the system animation.
The paper does not show which sensors are used to detect the emergency cases or how the
software is programmed, but they mentioned how the ladder logic is accomplished and, in the
conclusion, they mentioned that the system is functioning well.
In [9], they used a PLC and SCADA system to control three traffic light at the same time,
and they used, a ZigBee wireless system to communicate wirelessly between the PLCs and the
SCADAs. There are three PLCs, each one of them controlling one traffic light, and there is a
SCADA system with each PLC, to monitor the continues vehicles flow, and there is a main SCADA
system to control the hall process, and ZigBee wireless system used to connect the system PLCs and
SCADAs. Figure 14 below, shows and overview for the system designed.
10
In [9], they aimed to synchronize the three traffic light in order to achieve the best possible
vehicles flow, they used mathematical model to describe the traffic system, considering the flow
rate, vehicles density and velocity. They used dynamic traffic cellular automata (DTCA) method to
model the system, they chose ZigBee wireless system because of it is flexibility and the fault
tolerance and low cost. To achieve the selected model, they calculated the traffic lights cycle length,
cycle starting time and the duration of red, yellow and green lights cycles [9]. In the conclusion,
they mentioned that synchronizing using PLC/SCADA is achieved and the lead to continuous
vehicles flow.
In [10], they developed a mathematical model to calculate the optimum values for cycles time of
green, yellow and red lights. The model developed can be used with any controller to control a
traffic light with the optimum values for each time cycles. First, they describe the intersection set-
up, then they drive a model for vehicle que length and last, they show how the designed model will
work.
In [11, 12], a PLC used to control a traffic light and a mathematical model to calculate the
green light time based on vehicles number. They used photo electric sensors to detect the vehicles
presence (in their prototype) but they suggest using induction loop sensor in real system [11]. Also,
they used a software named TRILOGI to simulate the PLC, so they didn’t use a PLC in their system
design. In conclusion, the designed system can minimize the traffic congestion.
In [13], a PLC used to control the street lighting based on the day and night time. The idea of
reviewing this paper is to study the possibility of controlling the street lighting based on the
vehicle’s presence in the nighttime. Their design considers the seasonal variation to minimize the
power loss generated from unnecessarily lighting.
In [14], a programmable intelligent controller (PIC) is used to control a traffic light, they used an
IR sensor to measure the traffic density, they used a mathematical model to estimate the optimal
vehicles waiting time. In the system design, they used PIC microcontroller and LCD to display the
data and IR sensors to measure the density presence. Figure 15 below, show the PIC microcontroller
used in the system.
11
Almost all the papers reviewed are about controlling a traffic light or traffic flow, using PLC or
microcontroller the aims were the same. Different set of sensors were used among all reviewed
papers. But, the aims of using these types of sensors is to count vehicles number and detect vehicles
presence or measure vehicles weigh. In the next section, the methodology of this project is
illustrated.
12
4 Methodology
This section is to illustrate how the data will be collected from streets, and how these data will
be processed using a PLC. It is important to mention that, the system built in the lab does not use a
real data or a data collection sensors. The reason behind that is the difficulty of implementing the
designed system on real junction and using sensors to count vehicles number since the system is
designed and been tested in the lab only.
4.1 Data collection
To achieve the aims of this project, the data need to be collected is counting the vehicles number
on each street forming the junction, and the presence of priority case that need to bass immediately.
To collect these data and after comparing the advantages and disadvantages for different sensors,
one of the best sensors can be used is inductive loop sensors, these sensors are widely used in
counting vehicles number sense vehicles presence also it is cost relatively low [7].
Inductive loop is made by making one or more loops on the street ground using wires, then a
cable connecting the loop with a controller cabinet located nearby and an electronic unit located
nearby as well [15]. The electronic is transmitting energy to the wire loops at frequency from 10
KHz to 200 KHz. When a vehicle passes the loop the inductivity of the loop will decrease, if the
inductivity decreases, the electronic unit will send a pulse to the controller meaning of vehicle pass
or presence [15]. Figure 16 below, show two loops connected in series to an electronic unit.
Figure 16: Two inductive loops connected in series to an electronic unit [15]
This method of vehicle sensing is accurate and has a low installing and maintenance cost [15].
Second type of data needed is priority case presence. One of the best sensors can be used is
RFID (radio frequency identification). RFID uses an electromagnetic field to identify a tag, the tag
can store information can be read by a receiver [16]. Each tag can transmit a unique ID can be read
by the receiver, these mean the presence of a certain vehicles can be identified safely [16].
Nowadays RFID technology is used widely in many applications, like road troll, many countries are
applying a tariff on certain roads, they can identify each vehicle passing by supply a different tag for
each car, and install the tag reader on the desired road [16]. Same technology can be used to identify
the vehicles allowed to use priority pass, like ambulance or police car on a mission or maybe a VIP
13
car need to pass immediately. According to [16], this method of sensing is safe and fast, since the
tags able to transmit a crypto identification which can be identified by the installed reader only [16].
Also using this type of sensor is not expensive, sine the tag can cost between (1-5 US dollar per tag)
[16]. Each authorized vehicle will have a unique tag, this tag can be used when a priority pass
needed. A reader have to be installed above the road and far enough from the traffic light, the
distance between the reader and the traffic light will depend on the junction itself, if it is a busy
junction the distance will increase and if it is not busy junction the distance can be lower. When the
authorized vehicle pass under the reader and the tag is presented the signal will be green to the
direction that the vehicle coming from and red on the other sides and pedestrian will be red. When
the vehicle passes the junction every thins will be back to what it was before. There are two types of
tag, active and passive tags. Active tags use an external battery and higher frequency, but it can emit
the signal for up to 500 m or more in open area [16](technology is developing with the time, the
reference book published on 2010, nowadays some companies provides tags can emit the signal for
much longer distance especially in open areas ). While passive tags do not use a battery and it has a
smaller range (10 cm to 1meter) [16]. It is suggested to use active tags to allow the reader to follow
the vehicle presence until the vehicle pass the junction. Figure 17 below, illustrate the RFID system
with tag circuit.
Figure 17: RFID passive tag with reader antenna and reader and the tag circuit [16].
It’s important to note that, RFID is a huge market nowadays, the tags and reader manufacturer
provide a huge variety of products [16], choosing the readers and tags will depend on separate
research as strategic decision. There will be one reader above each street of the junction, each reader
represents the direction the priority comping from.
14
4.2 Data processing
Data type collected from the sensors, will be number of vehicles as an integer number, this
number will be counted using inductive loop sensor. And using RFID sensor the data type will be
Boolean, which meant 0 if no priority present or 1 if priority present. Since this project is about
design a control system for four-way traffic light, there will be inductive loop and RFID reader on
each direction. So, the data will be four number represent number of vehicles on each direction and
four Boolean data represent the priority presence on each direction, total ten input.
These inputs will be the PLC inputs, the PLC will use the program developed to achieve the
required outputs. Next section will illustrate the designed system (system description and the
hardware and programming) as a result for this project.
15
5 System simulation(prototype)
This section will present the practical work in this project. system description and the hardware
and software used, programming the PLC, and limitation faced during this project, and last part is to
conclude the results.
5.1 System description
The designed system is, PLC controlling a four-ways traffic junction with pedestrian signal. The
inputs are, three push buttons from star the operations, stop the operations and pedestrian request,
and eight switches, four of them represent a vehicles density on each side of the four-ways junction,
and the other four switches represent the priority case for each side of the four-ways junction. So,
the system has in total 11 inputs and 14 outputs. The outputs are, 4 yellow lights and five red light
and 5 green light. Each side of the junction has a signal contain one yellow and one green and one
red light, the pedestrian signal used, contain one green and one red light, only one signal for
pedestrian used because of the physical limitations of the system, but in reality, there should be
pedestrian signal for each side.
The designed system is working symmetrically, this mean each signal will perform
independently, only 1 signal will be green lighting at a time, and since its symmetric junction, when
green light open for any direction, the vehicles from that direction are allowed to turn right or go
straight or turn left or take a U-turn, because of that reason, when pedestrian signal is green, all other
vehicles signals must be red. Figure 18 below, shows the designed traffic junction.
It’s clear in figure 18 above, the designed system has 20 outputs. But, because of the
physical limitations that will be discussed later in section 5.4, and since the pedestrian signals are
working at the same time and triggered at the same time, only 1 pedestrian signal is used and only 1
16
push button for the pedestrian is used. But, in reality there should be four pedestrian signal as shown
in figure 18, and four push buttons for the pedestrians, each button related to only one of the
pedestrian signal, and in case of redesigning the traffic junction, only the PLC program has to be
modified while the physical wiring won’t be changed, this is the most significant benefit for the PLC
over the old relay wiring control, the flexibility. Because of what mentioned, the physical system
built in the lab, shown below in figure 19.
As shown in figure 19 above, only one pedestrian signal is used and only one pedestrian
push button is used. But they represent the four pedestrian signals and four pedestrian push buttons.
If same system used in reality, the four push buttons will be connected in parallel and the four
pedestrian lights will be connected in parallel also, this help in using only one input for the
pedestrian request and two output for the pedestrian signal, but if the junction design might be
change in the future, four different output will be used to trigger the pedestrian signal and eight
output for the pedestrian lights signal. This should be considered as a strategic plan for the junction
design. The junction built in the lab, shown in appendix 8.1(junction designed photo).
The system has four main functions, normal cycle, pedestrian case, high density case,
priority case, each of them illustrated below
17
5.1.1 Normal cycle
which mean signal 1 will start a sequence of 1 second yellow light (because it was red) then
8 second green light then 1 second yellow light then red until it starts again, then when signal 1 is
red, at the same time signal two will start the same sequence, then signal 3 then signal 4 then start
form signal 1 again. Figure 20 below, shows the function chart for the normal cycle.
It is noticeable in figure 20 above, signal 2 yellow light will start when yellow of the signal 1
is off, it’s a possible design to synchronize the two yellow lights to work at the same time, but is
avoided to give a delay between signal 1 green off and signal 2 green on, this to prevent possible
accident might happen, because some drivers won’t stop if they think that they can pass the junction
on the yellow light.
There is no timer for the red light in this design, whenever yellow or green is on the red light
will stop, this will be illustrated in the programming in section 5.3, if no interrupt case occur like
pedestrian or density or priority, this cycle will continue repeating as it is. The timing for yellow
light (1 second) and green light (8 second) is chose to be short to enable monitoring the system in
the lab, but in real cases the timing should be decided based on other researches, this project
interesting in control, but keep in mind, changing the time from control perspective is only a matter
of changing the timer value in the software, this will be illustrated in the programming in section
5.3.
18
5.1.2 Pedestrian case
Pedestrian function will interrupt the normal cycle if pedestrian request occurs. Figure 21
below, shows the function chart for the pedestrian case.
If pedestrian requested at any point, the controller will wait until the current on signal finish
it is own cycle, then instated of starting the next signal, the pedestrian signal will start green light for
10 seconds, then after 10 seconds, the pedestrian signal will change to red and the next signal cycle
will start, in the case of figure 21 above, the pedestrian requested when signal 3 is green, the
controller waited to the end of signal three cycle and then stared the pedestrian green light, and after
10 second pedestrian signal change to red and signal 4 started it is cycle. Pedestrian signal could
start after any signal cycle, signal 1,2,3 or 4. This design is chose by assuming this junction is
working in a city center where there are a lot of people crossing this junction, but in case of there are
not enough people crossing the junction, the design might allowed the pedestrian to pass after signal
4 only for example. Because this traffic light junction is controlled by PLC, it is only a matter of
changing the program to modify the pedestrian pass premises.
19
Figure 22: High density on signal 2 function chart
In figure 22 above, there is a high density at signal 2 direction, so the green light time will be
15 second instead of 8 second. In real case, the system will use inductive loop sensor to count
number of vehicles queuing in that direction , so the green light time will be variable depending on
number of vehicles, this method of control is done in the software only and how it is work is
illustrated in the programing in section 5.3.
5.1.4 priority case
priority function can interrupt any other function, when priority case occurs on any direction,
the yellow flash for 1 second on all signals, then green light of the priority direction will be on and
the red light for other direction will be on at the same time. Figure 23 below, shows the priority case
function chart.
20
In figure 23 above, there is a priority case coming from signal 4 direction, so a yellow light
will flash for 1 second on all directions to take the attention of all people who using that junction,
then the green light for signal 4 will start and all other signal will start red. When priority case is
gone, the signal will go back to what it was doing before the priority case occurs.
In case of there is more than one priority attended the junction at the same time, the signal
will accept the direction who trigger the priority first and when that priority is finished the other
priority will start after that, so only one priority will be activated at a time, the software running this
algorism will be illustrated in section 5.3.
21
5.2 Hardware
This section is about the hardware used to build the prototype, the PLC, LEDs (light emitting
diode), resistors and braid board used. Appendix 8.2, showing a photo for the designed system.
The PLC used is S7-1200 CPU 1215c DC/DC/DC from siemens, Figure 24 below, shows the
PLC used.
The power input for this PLC is 24 DC voltage and the sensors input voltage is 24 DC voltage
and the output is 24 DC voltage, so this what DC/DC/DC stand for. This PLC has 14 digital inputs
and 10 digital output, also 2 analog input and 2 analog output [17]. Since there is only 10 digital
outputs and the designed system required 14 digital outputs, a signal module is added to the system,
SM 1223 DC/DC add extra 8 digital inputs and 8 digital outputs. Figure 25 below on the left, shows
the added signal module.
22
The PLC with the signal module represents the controller used, the LEDs red, green and
yellow represent the actuators. Figure 26 below show the LEDs green, yellow and red.
These basic LEDs 5mm size, work on 2-volt DC and 20mA [18], but the PLC output is 24 volts,
so it can’t be connected directly to the PLC. In real case, the traffic light operates on 240 AC volt.
So, using a PLC with 240 AC input/output is recommended, no need for conversion, the controller
can control the light directly. But, in the prototype case, the 2-volt LEDs can be controller directly
using 24-volt PLC, the use of converter or resistors is mandatory. In the designed system, a 2.2K Ω
resistors with 0.25-watt capability is used to dissipate the rest of the power. Figure 27 below, show
the resistor used with color code red-red-red.
Figure 27: 2.2K Ω resistor and 0.25-watt capability, color code Red-Red-Red
Since the PLC output voltage is 24-volt and the LEDs operate on 2-volt, if they are
connected on series the voltage across the resistor will be 24-2=22-volt. From the basic ohm’s-law
𝑉
𝐼 = 𝑅 and the power 𝑃 = 𝐼 × 𝑉(no reference used since this law is a common knowledge) where I
is the current and V is the voltage and R is the resistance and P is the power. Since the power
capability for the resistor is 0.25-watt, the current chose to be limited to 10.9mA, so the power
across the resistor is 𝑃 = 22 × 0.0109 = 0.24 𝑤𝑎𝑡𝑡 which within the power capability, so the
current across the LED will be also 10.9mA since they are connected in series, while the maximum
operating current for the LED is 20mA, 10.9mA used, it was enough emitting to serve the purpose
of the LEDs, appendix 8.2 showing a photo for the system with the LEDs working on 10.9mA
current.
23
24𝑣𝑜𝑙𝑡
Limiting the current on 10.9mA was by using 2.2k Ω resistor depending on 𝑅 = 0.0109𝐴 =
2.2𝐾Ω. appendix 8.4, shows a photo for the resistors connected is series to the LEDs.
Another hardware used is the braid board, which is a standard board help with the wiring
instated of using PCB (printed circuit board), the reason of not using PCB is to save the cost of
designing a PCB and the ease of getting a braid board. The braid board used is shown in appeared in
appendix 8.4. next section of this report is about the software used to program the PLC and the
programming itself.
Last hardware used is the push buttons and switches, figure 28 below, shows the push button and
the switch used to energize the inputs.
24
5.3 Software and programming
The software used to program the PLC, is TIA portal v15.1, TIA stands for totally integrated
automation. This software developed by siemens company to program it is own PLCs and HMIs.
This software support three programming languages, ladder logic, function block diagram and
structured control language (SCL) which is like structured text language. figure 29 below, shows the
software interface.
Since there are four functions for the junction design, the programming description will be
divided into four sections. And the overall program shown in appendix 8.5.
5.3.1 Normal cycle program
First is to latch the start button, figure 30 below, shows how latching is made with ladder
logic, its noticeable that, pressing the stop button will stop the latch star, so everything will start by
pressing START push button and will stop by pressing STOP Push button.
25
The main feature of the normal cycle is that, it is a sequence of outputs, the end of one output
will be the start of the next output, as illustrated in system description section. Because of that
feature, TON timer has been used to control the all operations, TON timer is, a timer will change it
is output from 0 to 1 after the input time. Figure 31 below, shows how the first signal is
programmed.
From figure 31 above, when Latch start is energized, T1 (TON) timer and y1 (yellow 1) will
be energized at the same time, T1 when it is energized, will change it is output from 0 to 1 after 1
second. So, after 1 second from energizing T1, the output y1(yellow 1) will change from 1 to zero
because of the use of normally closed switch, and at the same time T2 and green 1 will be energized,
then after T2 given time, the green light will stop and at the same time T3 and y1.1(yellow 1) will be
energized. This logic is used until the last yellow light in signal 4, since there are 12 vehicles light,
so there are 12 TON timer (T1 to T12), at the end, T12 will energize the switch RESET, which is
shown in figure 31 above, RESET switch will reset the timer T1 and since T1 energizing T2 and T2
26
energizing T3 and so on until T12, this mean resetting T1 will reset all timers and start the sequence
again. Also, it is noticeable that the switch T1 is named “T1”.Q, this Q refer to the output, this mean
the switch will be on if timer T1 output on.
To make sure that red light will stop if the yellow or the green is on, the code shown in
figure 32 below is written for the red light.
From figure 32 above, if the green or yellow for signal 1 is on, the red light for the same
signal will be off. Otherwise, the red light is on.
5.3.2 Pedestrian program
Firs is latching the pedestrian, figure 33 below, show how pedestrian latched.
In figure 33 above, PD START is a push button, it is obvious that, to stop latching the
pedestrian, STOP button need to be triggered or (T Stop PD Latch) need to be triggered, which is a
TON timer for 10 second. So, after 10 second pedestrian latch will stop. As mentioned in the system
description, the pedestrian signal could start after any signal cycle ends. Figure 34 below, shows
how this achieved.
27
Figure 34: Pedestrian operation algorism in ladder logic
As shown in figure 34 above, in the first line, if the pedestrian is latched and T3(yellow 1) is
on and NOT T4 (yellow 2) is on, PD request 1 will be energized and T4 will not start until PD
request 1 is off again. This algorism applied for pedestrian request after signal 2, 3 and 4 as well.
Figure 35 below, shows how PD request is energizing the pedestrian green light and how the PD
request is stopped to complete the software execution.
28
Figure 35: Pedestrian green light control algorism
In figure 35 above, any pedestrian request will start the pedestrian green light and stop the
pedestrian red light, also any pedestrian request will start the (T Stop PD latch) timer, this timer is
responsible for stop latching the pedestrian request as mentioned before and complete the software
execution as it was before the pedestrian green light is on.
29
5.3.3 High density program
When high density is presented, the green light timer will be 15 second instated of 8 second.
This achieved by using MOVE block as shown in figure 36 below.
As shown in figure 36 above, if density was not triggered, 8 second only will be moved to
the memory location 2, and if density triggered, 15 second only will be moved to the memory
location 2. Memory location 2 is defined as a time and it is the time value for the TON timer
responsible for green light on. So, this how the variable timer T5 operate. This algorism applied for
the designed system in the lab because there is no vehicle number as an input, it is Boolean. But, in
real case, an inductive sensor will be used to measure the vehicles number as mentioned before, so
there is a need for different algorism depending on vehicles number. Figure 37 below, shows how
the green light timer will be managed in case of real system with vehicles number as an input.
30
Figure 37: Green light time depending on vehicle number
From figure 37 above, if vehicle number is available, a conditional switch will be used. If
vehicle number greater than zero and less than or equal to 20, the green light timer will be 30
second, and if vehicle number between 21 and 40 green light timers will be equal to 40 second and
so on. It is important to note that if vehicle number equal to zero this mean no vehicle waiting at that
direction of the junction, so the green light time will be equal to zero second, so the signal will stay
red and move to the next signal, this will save the drivers time and optimize the traffic light usage.
As mentioned before, this project interest in control perspective not in the appropriate green
light time depending on vehicles number, so the values 30, 40 and 60 second shown in figure 37
above is just an example to illustrate how the algorism work. In real case, it is possible to use as
many as required of move block to determine the best value for green light time depending of
vehicles number.
31
5.3.4 Priority program
In case of priority occurs at any direction, the software will stop executing the normal cycle
and the pedestrian codes, instated it will jump to the priority network. Figure 38 below, shows how
this guaranteed.
Figure 38 above, shows that any priority switch change to ON, this will energize (priority
request) and a jump function (JMP), this function will stop executing the software till it reach a
predefined label, in this case, a label named Priority. Figure 39 below, show the priority algorism
with the label Priority.
Figure 38 above, show the label Priority on the top left, so the execution will start from this
label and after it till the last software network. These two lines are responsible for priority for signal
1 direction and flashing the yellow for 1 second. The normally closed switches for the priority at
signal 1 line, guaranteed the no other priority is on, so only if no other priority on, priority 1 can be
activated, the latching has two switches connected as AND logic, (priority 1) to give the ability to
32
stop the latch in case of priority case end and (T Priority 1) will be on only if priority at signal 1
operation is started. It is obvious that whenever any priority started, this will start priority request
which will start the yellow flash block immediately and energize the corresponding TON timer, this
timer will after it is designated time(1 second) will stop the yellow light and start the block FC1
(Priority 1 block). Also it is noticeable that, the normally closed switches used in the first line,
named with ”IN”, this mean the input of the corresponding timer, if the timer input energized, this
mean the priority operation at that direction is started and this will stop the other priorities from
starting, so if two or more priorities energized, the first one will be latched, will start, and when it is
finished the second on will start then the third. Figure 40 below, shows Yellow flash block inside.
33
Figure 40 above, shows that when priority request is energized, Yellow flash block will turn all
yellow lights on, and all other lights will be turned off (R mean reset). Also, the block FC1 (priority
1) shown in figure 39, work on the same principle, it will stop all yellow lights and energize
pedestrian red and all other directions red light and will start the green light for that direction.
5.4 Limitation
The main limitation faced, was to have number of vehicles. It was not visible to use real sensors
installed in a real street to count vehicles number. So, the program developed using vehicles number
was not uploaded to the PLC, theoretically it should work well, but I was not tasted.
Another limitation was faced, the physical area of the braid board used, was not sufficient to
connected four pedestrian signals, this is shown in appendix 8.1.
Another limitation, the resistors used to limit the current, were getting hot if the system operate
for more than 30 minutes. This because the resistors operating power was 0.24-watt and the
maximum power was 0.25-watt. And, if resistors with higher value used, the light emitting won’t be
clear. So, using resistors with 0.5-watt capability is recommended as it is not efficient if the resistors
were operating near to the maximum capability.
34
6 Improvement area for future work
This section is about suggestion to improve this project in the future. There are two suggestions,
first is using a SCADA system to control the traffic on wider geographical area, and second is to use
GPS (global positioning system) to continuously monitor the traffic to perform more adaptive
controller. Both suggestions are described below.
6.3 Controlling traffic by SCADA system
SCADA system used to collect data from different PLCs, send commands to those PLCs and
showing the overall system in HMI to make system monitoring and real time controlling easier.
If each signal within a city, controlled by PLC to perform a smart traffic light which can give
different output depending on vehicles using that junction at that time as illustrated in this project.
Next step to develop this project, is to connect all the PLC to one SCADA system to monitor the all
system and synchronize all controller to perform as one controlling serving one purpose which is
maximize road usage efficiency, if all PLCs controlled by SCADA system, by improving the over
all system, the driver can pass a sequence of signals without stopping, this can be achieved by
calculating the time needed to reach the next signal from the first signal, within this time the next
signal will change to green and the third signal will be green when the driver arrive. This concept
studied and shown in [9]. But the improvement suggested here, is to use same control algorism
developed in this project and add a lot more junctions to be controlled by the SCADA system. The
system goal will be a synchronized smart traffic control within a city.
6.4 Continues traffic tracking by GPS system
Monitoring and controlling traffic lights is not the most efficient way to solve congestions within
a city. Nowadays, GPS devices is widely used to follow locations accurately and online. For
example, anybody using Google maps, can notice that the application can show the congestions in
red color accurately on the map. Google map is an application developed by google company, it is
using phone GPS to determine the location and speed and by collecting the data from all it us users,
the app can detect the congestions. By using the same concept and provide all vehicles within a
country with a GPS device, and use a software to monitor all vehicles location and speed, and then
feed these data into the SCADA system to be used to drive a better control algorism to achieve the
maximum level of control in term of maximize road usage efficiency. For example, if a certain road
has congestion, the SCADA system will detect that and make all signals leading to that road slower
by increase red light time, and all signal leading to go out from that road faster by increase green
light time. This idea of control is working well logically, but to measure how much it will affect a
total city traffic, the system needs to be built and simulated.
35
7 Conclusion
In conclusion, the five PLC programming language illustrated, ladder logic, function block
diagram, sequential function chart, instruction list and structured text. Ladder logic chose to be the
language used in this project. Then the PLC architecture discussed and described. Many papers and
research considered in the literature review, but most of them has common objective which is
control a smart traffic light. The methodology used in this research, is to measure vehicles number
using inductive loop sensors and to indicate the authorized priority cases with radio frequency
identification technology, the of these sensors will be used is illustrated in the methodology section.
Then system developed in this project described. The system is a four-way junction traffic light,
need to be controlled using Siemens PLC S7-1200 CPU 1215c, the system has four main functions.
Which are, normal cycle in case in case all street forming the junction has equal density, and
pedestrian signal in case the pedestrian need to pass the junction, and high density function in case
vehicle waiting on one side of the junction more than the other sides and priority function in case an
ambulance or police car in a mission and need to pass the junction immediately. All these functions
described well and illustrated. The program controlling the junction and providing these four
junctions was written by ladder logic language, the program explained, and it is different aspects
illustrated. The system operations as the following points
*Normal cycle always works as usual unless it is interrupted by pedestrian or high density or
priority.
* In case of pedestrian requested, after the end of the current signal cycle, the pedestrian
signal will start, then the normal cycle will complete after pedestrian signal back to red again.
*In case of high density on any side of the junction, the green light time will be increased in
relationship with vehicles number.
*If priority occurs, the signal will open green to the priority direction and red light to the
other directions.
All these functions achieved by using the developed program with the PLC. There was a
physical limitations and software limitations. The physical limitations, the braid board are was now
wide enough and used resistors were operation near by the maximum limit. The software
limitations, number of vehicles can not be used within the software because it is not visible to use
real inductive loop sensor in a real road to measure vehicles number. So, high density used as a
Boolean function, if it exists, green light time increase, if not, nothing happens. Future improvement
suggested, first is to use SCADA system to control more than one PLC in term of synchronize the
system within a city to give better performance. Another suggestion is to use GPS to follow the
speed and location of all vehicles, to detect the congestion directly and the SCADA system can
implement a solution to improve traffic flow.
At the end, the aims of this project is to program a PLC to control a traffic light and allowed the
pedestrian to pass the junction safely, and provide an algorism to control the junction in case of high
vehicles density, and program a priority function allowed authorized emergencies to pass the
junction in fast way. All these aims have been achieved and the controller developed is working well
as it was aimed.
36
7 References
[2] K. Smith, "Industrial Automation, Robotics & Artificial Intelligence, Black Board," [Online].
Available: https://blackboard.ncl.ac.uk/bbcswebdav/pid-3571751-dt-content-rid-
12562347_1/courses/K1819-EEE8005/Notes%20Lecture%204%20KS%20V4.pdf. [Accessed
13 07 2019].
[3] J. H. Karl and T. Micheal , IEC 61131-3:Programming Industrial Automation system: concepts
And Programming Languages, Requirements for Programming Systems, AIDS to Decision-
making Tools 2nd edition, Springer Science & Business Media, 2009.
[4] E. Mueller, "Aspects of the history of traffic signals," IEEE Transactions on Vehicular
Technology, vol. 19, no. 1, pp. 6-17, Feb 1970.
[5] M. Dev Srivastava, S. Sachin, S. Sumedha, U. Tyagi and A. Professor, "SMART TRAFFIC
CONTROL SYSTEM USING PLC and SCADA," International Journal of Innovative
Research in Science, Engineering and Technology, vol. 1, no. 2, pp. 169-172, 2012.
[6] A. K. Emad , "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, 2011.
[8] Y. Liu and X. F. Chen, "Design of traffic lights controlling system based on PLC and
configuration technology," 1st International Conference on Multimedia Information
Networking and Security, MINES 2009, vol. 2, no. Nov 2009, pp. 561-563, 2009.
[9] H. Eren, A. Pakka, A. Alghamdi and Y. Yue, "Instrumentation for safe vehicular flow in
intelligent traffic control systems using wireless networks," in Conference Record - IEEE
Instrumentation and Measurement Technology Conference, Perth, WA, Australia, 2013.
[10 B. Schutter and B. Moor, "Optemal Traffic light control for a single Intersection," European
] Jornal of Control, vol. 4, no. 1, pp. 260-276, 1998.
[11 M. A. Khattak, "PLC Based Intelligent Traffic Control System," International Journal of
] Electrical & Computer Sciences IJECS-IJENS, vol. 11, no. 06, pp. 69-73, 2011.
37
[12 R. Martínez-rodríguez-osorio, M. Calvo-ramón, A. Miguel and L. C. Navarrete, "Smart control
] system for LEDs traffic-lights based on PLC," in Proceedings of the 6th WSEAS International
Conference on Power Systems, Lisbon, Portugal, 2006.
[13 D. Latha, K. Sudha and S. Devabhaktuni, "PLC based Smart Street Lighting Control,"
] International Journal of Intelligent Systems and Applications, vol. 6, no. 1, pp. 64-72, 2013.
[14 B. Ghazal, K. Elkhatib, K. Chahine and M. Kherfan, "Smart traffic light control system," in
] 2016 3rd International Conference on Electrical, Electronics, Computer Engineering and their
Applications, EECEA 2016, Beirut, 2016.
[15 "Federal Highway Administration Research and Technology," Chapter 2, Traffic Detector
] Handbook: Third Edition—Volume I, May 2006. [Online]. Available:
https://www.fhwa.dot.gov/publications/research/operations/its/06108/02.cfm. [Accessed 7 8
2019].
[16 K. Finkenzeller, RFID Handbook: Fundamentals and Applications in Contactless Smart Cards,
] Radio frequency identification and near-field communication, West Sussex, UK: John Wiley &
Sons Ltd, 2010.
38
8 Appendices
8.1 junction designed photo
39
40
8.2 system designed photo
41
8.3 PLC and signal module photo
42
8.4 Resistors connected in series
43
8.5 overall program (Main OB, P1, P2, P3, P4 and yellow flash)
44
45
46
47
48
49
50
51
52
53
Yellow flash block
54
Priority 1 block
55
Priority 2 block
56
Priority 3 block
57
Priority 4 block
58