Moving Vehicle Traffic Controller.

(1)

MOVING VEHICLE TRAFFIC CONTROLLER

Shafrein Izwan Bin Hasshim

Bachelor in Mechatronic Engineering May 2009


(2)

i

“I hereby declared that I have read through this report and found that it has comply the partial fulfillment for awarding the degree of Bachelor of Mechatronic Engineering”

Signature : _______________________________________

Supervisor’s Name : PROF MADYA MOHD ARIFF BIN MAT HANAFIAH


(3)

ii

MOVING VEHICLE TRAFFIC CONTROLLER

SHAFREIN IZWAN BIN HASSHIM

This Report is submitted in partial fulfillment of requirements for the Degree of Bachelor in Mechatronic Engineering

Faculty Of Electrical Engineering

UNIVERSITI TEKNIKAL MALAYSIA MELAKA


(4)

iii

DECLARATION

“I hereby declared thatthis report entitled ‘Moving Vehicle Traffic Controller is a result of my own work except for the excerpts that have been cited clearly in the references.”

Signature : _______________________

Name : SHAFREIN IZWAN BIN HASSHIM Date : APRIL 2009


(5)

iv

DEDICATION

For my beloved father, Hasshim Bin Jantan and mother, Siti Zabariah Binti Zainal, and also to lectures and all my friends.


(6)

v

v ACKNOWLEDGEMENTS

First of all, I would like to express my thankfulness and gratitude to Allah S.W.T who has given me all the strength that I needed to complete this final year project (FYP 2) and also to prepare this report.

With this opportunity, I would like to express my gratitude to the Faculty of Electrical Engineering (FKE), Universiti Teknikal Malaysia Melaka (UTeM) generally, and especially to my supervisor Prof. Madya Mohd Ariff Bin Mat Hanafiah for the help, advices and guidance that he gave during this project.

Not forget also to my parents, a million of thanks to them because of their support to me. Last but no least, I would like to thank all my friends from 4 BEKM whom have been such wonderful friends to me and also to everyone who was involved in the completion of this project. I would like to thank them for all support and encouragement to me who have given me the courage and wisdom to fulfill my final year project. Thank you.


(7)

vi

ABSTARCT

This project is to design and develop an intelligent system named Moving Vehicle Traffic Controller. Basically, this system aids are PLC, limit switch, relay and control car. Limit switch is an input for the PLC while traffic light, crossbar, relay and control cars as the outputs for the PLC. A sensor on the track will transmit the signal to PLC when receives a signal. Generally, this system contains a roadway, road train, traffic light and crossbar. When the main start button is pressed, the system will start operate automatically, the cars, traffic light and train. The cars in this project are wireless control cars that using relays interfacing that get signals from roadway. The cars only stop when the traffic light turns to red and when the crossbar closes. The cars will continue moving when the traffic light turns to green or the crossbar open. For the traffic light operations, when the sensor contact, it will give a signal to the PLC, so that the car can stopped if the traffic light is red. The output from PLC also will contact to the relay interface and give a signal to wireless control car.


(8)

vii

ABSTRAK

Projek ini adalah bertujuan untuk mereka bentuk dan membangunkan satu sistem pintar yang dinamakan ‘Moving Vehicle Traffic Controller’. Pada asasnya, sistem ini terdiri daripada PLC, suis sesentuh, geganti dan kereta kawalan jauh. Suis sesentuh adalah sebagai input kepada PLC manakala lampu isyarat, palang, geganti dan kereta kawalan jauh sebagai keluaran bagi PLC. Satu penderia di atas trek akan menghantar isyarat untuk PLC apabila ia menerima isyarat daripada keretapi atau kereta kawalan jauh. Umumnya, sistem ini mengandungi trek keretapi dan kereta kawalan jauh, lampu isyarat dan palang. Apabila suis utama di tekan, sistem akan mula beroperasi secara automatik, termasuk kereta, lampu isyarat dan kereta api. Kereta-kereta dalam projek ini adalah kawalan wayarles menggunakan geganti yang menerima isyarat daripada PLC. Kereta hanya akan berhenti apabila lampu isyarat bertukar merah dan apabila palang ditutup. Apabila lampu isyarat bertukar hijau atau palang terbuka, kereta akan kembali beroperasi. Untuk operasi lampu isyarat, apabila penderia diaktifkan, ia akan memberi isyarat kepada PLC, supaya kereta boleh berhenti apabila lampu isyarat bertukar merah. Keluaran daripada PLC juga akan memberi satu isyarat kepada geganti seterusnya isyarat wayarles kereta kawalan jauh.


(9)

viii

TABLE OF CONTENTS

CHAPTER TITLE PAGE

ADMISSION i

TITLE PAGE ii

DECLARATION iii

DEDICATION iv

ACKNOWLEDGEMENT v

ABSTRACT vi

ABSTRAK vii

TABLE OF CONTENTS viii-ix

LIST OF TABLES x

LIST OF FIGURES xi-xii

1 INTRODUCTION

1.1 Definition 1

1.2 Project Overview 1

1.3 Problem Statements 2

1.4 Project’s Objective 3

1.5 Project scope 3

2 LITERATURE REVIEW

2.1 Introduction 4

2.2 First Review 4

2.3 Second Review 5

2.4 Third Review 9

2.5 Fourth Review 17


(10)

ix

2.7 Sixth Review 25

3 PROJECT BACKGROUND

3.1 Project Background 29

3.2 Programmable Logic Controller (PLC) 30

3.3 Theory of Sensors 33

3.4 Theory of Pneumatics 35

4 METHODOLOGY

4.1 Introduction 40

4.2 Process flowchart of the project 42

4.3 Project methodology 43

4.4 Gantt chart 44

4.5 Hardware Development 45

4.6 Software Development 56

5 RESULT AND ANALYSIS

5.1 Introduction 66

5.2 Traffic Light at Four Junction Operation 66

5.3 Crossbar Operation 69

5.4 SCADA 70

6 DISCUSSION, CONCLUSION AND

RECOMMENDATION

6.1 Discussion 74

6.2 Conclusion 75

6.3 Recommendation 76

LIST OF REFERENCES APPENDICES


(11)

x

LIST OF TABLES

TABLE TITLE PAGE

4.1 Gantt chart 44

4.2 Sensor specification 50

4.3 Input Components 56

4.4 Output Components 57

4.5 Input Address 58 4.6 Output Address 58


(12)

xi

LIST OF FIGURES

FIGURE TITLE PAGE

1.1 Controller System 2

2.1 VANET System 6

2.2-2.10 Traffic light using MATLAB Simulation 9-14 2.11 Fuzzy logic controller for 4-lane traffic 18

2.12 Input Fuzzy Variable 19

2.13 20 output sequencing circuit PCB 20

2.14 20 Output Sequencing Circuit 21

2.15 20 Step LED Circuit 23

2.16 20 Step Traffic Light Schematic 24

2.17 20 Output Sequencing Circuit PCB 26 2.18 20 Output Sequencing Circuit Diagram 26

2.19 MEL-12 Sensor Position 28

3.1 5 major parts of the project 29

3.2 Flows of PLC’s input and output section 32

3.3 Capacitive Sensor 33

3.4 Photoelectric Sensor 34

3.5 Solenoid valve 37

3.6 Pneumatic Cylinders 38

4.1 Project Process Flowchart 42

4.2 Flowchart of project methodology 43

4.3 Track Design 45

4.4 Car Track Design 46

4.5 Train Track Design 46


(13)

xii

4.7 Prototype model of the track 48

4.8 Car track 49

4.9 Sensor Output Circuit 50

4.10 Through-beam sensor Emitter circuit 51

4.11 Sensor Adjustment 51

4.12 Sensor input circuit to PLC 52

4.13 Traffic Light model 53

4.14 Traffic Light Circuit 54

4.15 Wiring relay for traffic light 54

4.16 Crossbar Area 55

4.17-4.18 Ladder Diagram 59

4.19-4.26 SCADA development 61-65

5.1 LED Traffic Light 66

5.2 Moving Vehicle Traffic Light Controller Model 67

5.3-5.4 Traffic Light Output 68-69

5.5 Crossbar Operation 69

5.6 Traffic Light system 70

5.7 Crossbar 1 71

5.8 Crossbar 2 71

5.9 Sensor Controller 72


(14)

CHAPTER 1

INTRODUCTION

1.1 Definition

A control system is a device or set of devices to manage, command, direct or regulate the behaviour of other devices or systems. This project is categorized in on/off control. In most applications of on-off feedback control, some consideration needs to be given to other costs. Therefore, practical on-off control systems are designed to include hysteresis, usually in the form of a deadband, a region around the setpoint value in which no control action occurs. The width of deadband may be adjustable or programmable. Larger more complex systems can be controlled by a Distributed Control System (DCS) or Supervisory Control and Data Acquisition (SCADA) system.

1.2 Project Overview

This project is the integration between programmer logic controllers (PLC), and sensors. This project is divided into two stations, which are mechanical part and electrical part. The mechanical parts are consisting of mechanical drawing, measuring, fabrication and assembly. The electrical parts are consisting of electrical drawing, electrical wiring, programming testing, and troubleshooting. General overview of the controller system is as shown in Figure 1.1 below.


(15)

2

Figure 1.1: Controller System

1.3 Problem statements

 To reduced manpower to operate the train gate across the road.

 System operated by human that is not efficient in handling traffic movement.

 Unexpected incident due to lack of awareness of the train gate operator.

 The existing system is static and very hard for student to understand.

 Can be used as training kit so teaching and learning process will be more effective

Input

PLC

Output

Crossbar1 Crossbar2 Traffic lights

(1,2,3,4) Relay interfaces

(Car 1, Car 2) Transmitter

Module (Car 1, Car 2)

Sensors Start/Stop


(16)

3

1.4 Objectives of the project

The project is aimed to meet the following objectives:

 To design a model of roadway system that can simulate the operation of traffic control system.

 To design a wireless control car using a relay interface that can get signals from the roadway.

 To design an automatic crossbar that utilizes the uses of pneumatic.

 To build a model kit to portray the traffic system for students. 1.5 Scope of the project

The scope of this project is to study the model of traffic controller system and with the PLC as the controller to monitor the traffic behavior. In this project also, the proximity/photoelectric sensor will be studied to detect the cars at traffic light and while crossing the train gate. Besides that, the scope is to learn the mechanism for the crossbar that utilizes the pneumatic system. In order to achieve the objective of the project, a suitable program is developed. Then, the hardware part which consists the indicator light that will be use as a traffic light and pneumatic cylinder as the crossbar at train gate.


(17)

CHAPTER 2

LITERATURE REVIEW

2.1 Introduction

Several numbers of books, catalogues, technical manuals and also on-line references have to be studied in order to identify and come-up with suitable hardware, components, and software to make this project successful. The existing control systems can also be referred for further improvement.

2.2 First Review: Traffic Light System Using BASIC STAMP 2 (BS2)

Many traffic light systems operate on a timing mechanism that changes the lights after a given interval. An intelligent traffic lights system senses the presence or absence of vehicles and reacts accordingly. The idea behind intelligent traffic system is that drivers will not spend unnecessary time waiting for the traffic lights to change.

The older system uses weight as a trigger mechanism. Current traffic system react to motion trigger the light changes. Once the infrared object detector picks up the presence of a car, a switch causes the light to change. In order to accomplish this, algorithms are used to govern the actions of the traffic system. While there are many different programming languages today, some programming concepts are universal in Boolean Logic [1].


(18)

5

The traffic signal system consists of three important parts. The first part is controller, which represents the brain of the traffic system. It consists of a computer that controls the selection and timing of traffic movements in accordance to the varying demands of traffic signal as registered to the controller unit by sensors [2]. The second part is the signal visualization or in simple words is signal face. Signal faces are part of a signal head provided for controlling traffic in a single direction and consists of one or more signal sections. These usually comprise of solid red, yellow, and green lights. The third part is the detector or sensor. The sensor or detector is a device to indicate the presence of vehicles. One of the technologies today, consists of wire loops placed in the pavement at intersections. They are activated by the change of electrical inductance caused by a vehicle passing over or standing over the wire loop. Recent technology utilization is video detection. A camera feeds a small computer that can “see” if a vehicle is present.

BASIC STAMP 2 (BS2) is used as the microcontroller of the traffic signal. The BS2, which needs to be plugged to the Board Education (BoE), is directly attached to the computer in order to program it.

2.3 Second Review: Traffic Lights Using Car-to-Car Communication

Advances in mobile computing and wireless communication have offered new possibilities for Intelligent Transportation Systems (ITS), aiming at improving driving safety and traffic efficiency. By adding short-range wireless communication capabilities to vehicles, the devices form a mobile ad-hoc network, allowing cars to exchange information about road conditions. This is referred as Vehicular Ad-hoc Networks (VANETs) [3].

Traffic safety is the focus of current research on VANETs and the main motivation of deploying this technology and to make it ubiquitous. However, there are a number of other applications that could improve the way people drive today.


(19)

6

The paper examines the possibility of deploying an adaptive signal control system in intersections, a system that can base its control decision on information coming from cars. It is assume that each vehicle is equipped with a short-range wireless communication device, as is a controller node placed in the intersection with traffic lights (figure 2.1).

Figure 2.1: VANET System

There are several goals that can be taken into consideration when designing a signal control mechanism, like minimizing the average delay of vehicles approaching an intersection, increasing progression by coordinating vehicle platoons between intersections, reducing the queue length of all approaches to an intersection and even reducing overall fuel consumption and pollutant emissions.

The main measure of effectiveness (MOE) for an intersection is the control delay, which is the component of vehicles’ delay caused by the presence of the signal control [3]. It is measured in comparison with the travel time calculated in the absence of a control mechanism. Another relevant parameter is v/c or volume per capacity ratio, which reflects the degree of saturation of an approach to the intersection. For saturated


(20)

7

intersections, the degree of saturation is calculated through the demand per capacity ratio which is greater than 1.

Several adaptive traffic control systems have been implemented for intersections all over the world. Some of the most important ones include Split, Cycle and Offset Optimization Technique (SCOOT) and Sydney Coordinated Adaptive Traffic System (SCATS) [4]. SCOOT is based on loop detectors placed on every link to an intersection, usually at the upstream end of the approach. Other systems, including SCATS, have detectors placed immediately before the stop line at an intersection. Thus, they cannot get accurate data when the queue grows beyond the length of the detector, or the link is over saturated. Since they use a model based especially on occupancy, they also have difficulties in differentiating between high flows or intersection stoppage. Reported research shows poor performance when incidents occur.

Adaptive traffic lights based on wireless communications with the vehicles can employ greater flexibility than the ones mentioned above as they are provided with more information for the signal decision process (e.g. vehicles positions and speeds). The cost is also significantly lower considering loop detectors are usually installed in the asphalt under each lane approaching the intersections and cameras require high processing power. If all vehicles will be equipped with wireless communication devices, then all that is needed is wireless devices with some processing power in intersections.

By making use of wireless communication and GPS, it enables vehicles to collect and disseminate traffic information and, finally, to provide meaningful data to the driver. Vehicles periodically transmit information about themselves and other cars they know about. They use one-hop broadcasts to avoid a broadcast storm. Each record consists of a position, identification number, speed, direction, state and a timestamp of the moment when the information was created.

The traffic light controller listens to all the information the cars are exchanging, thus finding out how crowded the intersection approaches are. In a city environment,


(21)

8

controllers in adjacent intersections may communicate through a wired network, in order to provide each other with additional information. For every vehicle record received, the controller checks it against its local database. If the vehicle wants to pass through the controlled intersection and there is no newer record about this vehicle in the database, the record will be stored and taken into account when calculating link parameters.

The control method benefits from the wireless communication system with vehicles and can accurately determine traffic metrics. The most important metrics were use are control delay and queue length. The control delay is calculated for each car that passes through an intersection. It is the difference between the estimated travel time in the absence of the intersection control and the travel time reported by a vehicle, in the presence of the intersection control. The queue length is computed by the traffic controller, which knows the traffic configuration at every moment.

The controller keeps track of the vehicles throughout the entire period when they are in a few miles range around the intersection (through the information propagation scheme of Traffic View), so it is able to measure accurately both volume and demand. The timing plan generation process takes place once during each cycle and establishes a plan for the following cycle based on the measured parameters [3].

There are possibilities that the traffic lights broadcast feedback messages for the incoming cars giving information such as when the phase will switch or how large the queue is on each lane of every approach. Feedback messages have several benefits. First, they increase safety as drivers will not be surprised by the end of the green phase. Furthermore, they can adapt their speed accordingly (avoid useless accelerations or react faster on green). Fuel consumption and pollutant emissions are thus reduced. Moreover, in-vehicle software could recommend appropriate speeds based on when the current phase will end, and how many cars are already queued.


(22)

9

2.4 Third Review: Traffic Light Control Simulation Using MATLAB

Consider a situation where there is a junction. In order to ensure that the flow of the traffic run smoothly, traffic lights are very much needed. So in this simulation program, several parts are constructed, four functional traffic lights and four cars that can move when a traffic light at their junction turns green (figure 2.2).

Figure 2.2

The very first to do is to build its frame or working area. The working area is about 10 x 10.


(23)

10

[x4,y4] [x3,y3]

[x1,y1] [x2,y2]

Figure 2.3 Figure 2.4

fill is a MATLAB function to create a polygon defined by column vector x and y as in figure 2.3 and 2.4.

fill([x1 x2 x3 x4], [y1 y2 y3 y4], ...

‘face color’, [.5 .5 .5], ‘edge color’, [.5 .5 .5]);

Create a vertical road.

fill ([4 6 6 4],[0 0 10 10], [.5 .5 .5], 'edge color', [.5 .5 .5])

Create a horizontal road.

fill ([0 10 10 0],[4 4 6 6], [.5 .5 .5], 'edge color', [.5 .5 .5])

For a traffic light, there are three lights in a row; red, yellow and green; and they have to appear in a circular shape. MATLAB did not have a specific function to create a circle. However, it did not mean that it cannot draw but it needs to play with mathematical equation. In MATLAB, a circle can be drawn if the equation is known. Fill function is still useful to create the circle.


(24)

11

t = 0:pi/20:2*pi;

Circle=fill(x + r*sin(t), y + r*cos(t), 'r');

With r as radius for the circle; and x and y is the center point of the circle. Positioning those circles at every junction with respect to the traffic light color order.

% Traffic Light t = 0: pi/20:2*pi;

% Traffic Light 1

TL1r=fill (3.7 + 0.2*sin(t), 3.7 + 0.2*cos(t), 'r'); TL1y=fill (3.7 + 0.2*sin(t), 3.2 + 0.2*cos(t), 'y'); TL1g=fill (3.7 + 0.2*sin(t), 2.7 + 0.2*cos(t), 'g');

% Traffic Light 2

TL2r=fill (6.3 + 0.2*sin(t), 3.7 + 0.2*cos(t), 'r'); TL2y=fill (6.8 + 0.2*sin(t), 3.7 + 0.2*cos(t), 'y'); TL2g=fill (7.3 + 0.2*sin(t), 3.7 + 0.2*cos(t), 'g');

% Traffic Light 3

TL3r=fill (6.3 + 0.2*sin(t), 6.3 + 0.2*cos(t), 'r'); TL3y=fill (6.3 + 0.2*sin(t), 6.8 + 0.2*cos(t), 'y'); TL3g=fill (6.3 + 0.2*sin(t), 7.3 + 0.2*cos(t), 'g');

% Traffic Light 4

TL4r=fill (3.7 + 0.2*sin(t), 6.3 + 0.2*cos(t), 'r'); TL4y=fill (3.2 + 0.2*sin(t), 6.3 + 0.2*cos(t), 'y'); TL4g=fill (2.7 + 0.2*sin(t), 6.3 + 0.2*cos(t), 'g');


(1)

The paper examines the possibility of deploying an adaptive signal control system in intersections, a system that can base its control decision on information coming from cars. It is assume that each vehicle is equipped with a short-range wireless communication device, as is a controller node placed in the intersection with traffic lights (figure 2.1).

Figure 2.1: VANET System

There are several goals that can be taken into consideration when designing a signal control mechanism, like minimizing the average delay of vehicles approaching an intersection, increasing progression by coordinating vehicle platoons between intersections, reducing the queue length of all approaches to an intersection and even reducing overall fuel consumption and pollutant emissions.

The main measure of effectiveness (MOE) for an intersection is the control delay, which is the component of vehicles’ delay caused by the presence of the signal control [3]. It is measured in comparison with the travel time calculated in the absence of a control mechanism. Another relevant parameter is v/c or volume per capacity ratio, which reflects the degree of saturation of an approach to the intersection. For saturated


(2)

intersections, the degree of saturation is calculated through the demand per capacity ratio which is greater than 1.

Several adaptive traffic control systems have been implemented for intersections all over the world. Some of the most important ones include Split, Cycle and Offset Optimization Technique (SCOOT) and Sydney Coordinated Adaptive Traffic System (SCATS) [4]. SCOOT is based on loop detectors placed on every link to an intersection, usually at the upstream end of the approach. Other systems, including SCATS, have detectors placed immediately before the stop line at an intersection. Thus, they cannot get accurate data when the queue grows beyond the length of the detector, or the link is over saturated. Since they use a model based especially on occupancy, they also have difficulties in differentiating between high flows or intersection stoppage. Reported research shows poor performance when incidents occur.

Adaptive traffic lights based on wireless communications with the vehicles can employ greater flexibility than the ones mentioned above as they are provided with more information for the signal decision process (e.g. vehicles positions and speeds). The cost is also significantly lower considering loop detectors are usually installed in the asphalt under each lane approaching the intersections and cameras require high processing power. If all vehicles will be equipped with wireless communication devices, then all that is needed is wireless devices with some processing power in intersections.

By making use of wireless communication and GPS, it enables vehicles to collect and disseminate traffic information and, finally, to provide meaningful data to the driver. Vehicles periodically transmit information about themselves and other cars they know about. They use one-hop broadcasts to avoid a broadcast storm. Each record consists of a position, identification number, speed, direction, state and a timestamp of the moment when the information was created.

The traffic light controller listens to all the information the cars are exchanging, thus finding out how crowded the intersection approaches are. In a city environment,


(3)

controllers in adjacent intersections may communicate through a wired network, in order to provide each other with additional information. For every vehicle record received, the controller checks it against its local database. If the vehicle wants to pass through the controlled intersection and there is no newer record about this vehicle in the database, the record will be stored and taken into account when calculating link parameters.

The control method benefits from the wireless communication system with vehicles and can accurately determine traffic metrics. The most important metrics were use are control delay and queue length. The control delay is calculated for each car that passes through an intersection. It is the difference between the estimated travel time in the absence of the intersection control and the travel time reported by a vehicle, in the presence of the intersection control. The queue length is computed by the traffic controller, which knows the traffic configuration at every moment.

The controller keeps track of the vehicles throughout the entire period when they are in a few miles range around the intersection (through the information propagation scheme of Traffic View), so it is able to measure accurately both volume and demand. The timing plan generation process takes place once during each cycle and establishes a plan for the following cycle based on the measured parameters [3].

There are possibilities that the traffic lights broadcast feedback messages for the incoming cars giving information such as when the phase will switch or how large the queue is on each lane of every approach. Feedback messages have several benefits. First, they increase safety as drivers will not be surprised by the end of the green phase. Furthermore, they can adapt their speed accordingly (avoid useless accelerations or react faster on green). Fuel consumption and pollutant emissions are thus reduced. Moreover, in-vehicle software could recommend appropriate speeds based on when the current phase will end, and how many cars are already queued.


(4)

2.4 Third Review: Traffic Light Control Simulation Using MATLAB

Consider a situation where there is a junction. In order to ensure that the flow of the traffic run smoothly, traffic lights are very much needed. So in this simulation program, several parts are constructed, four functional traffic lights and four cars that can move when a traffic light at their junction turns green (figure 2.2).

Figure 2.2

The very first to do is to build its frame or working area. The working area is about 10 x 10.


(5)

[x4,y4] [x3,y3]

[x1,y1] [x2,y2]

Figure 2.3 Figure 2.4

fill is a MATLAB function to create a polygon defined by column vector x and y as in figure 2.3 and 2.4.

fill([x1 x2 x3 x4], [y1 y2 y3 y4], ...

‘face color’, [.5 .5 .5], ‘edge color’, [.5 .5 .5]);

Create a vertical road.

fill ([4 6 6 4],[0 0 10 10], [.5 .5 .5], 'edge color', [.5 .5 .5])

Create a horizontal road.

fill ([0 10 10 0],[4 4 6 6], [.5 .5 .5], 'edge color', [.5 .5 .5])

For a traffic light, there are three lights in a row; red, yellow and green; and they have to appear in a circular shape. MATLAB did not have a specific function to create a circle. However, it did not mean that it cannot draw but it needs to play with mathematical equation. In MATLAB, a circle can be drawn if the equation is known. Fill function is still useful to create the circle.


(6)

t = 0:pi/20:2*pi;

Circle=fill(x + r*sin(t), y + r*cos(t), 'r');

With r as radius for the circle; and x and y is the center point of the circle. Positioning those circles at every junction with respect to the traffic light color order.

% Traffic Light t = 0: pi/20:2*pi;

% Traffic Light 1

TL1r=fill (3.7 + 0.2*sin(t), 3.7 + 0.2*cos(t), 'r'); TL1y=fill (3.7 + 0.2*sin(t), 3.2 + 0.2*cos(t), 'y'); TL1g=fill (3.7 + 0.2*sin(t), 2.7 + 0.2*cos(t), 'g');

% Traffic Light 2

TL2r=fill (6.3 + 0.2*sin(t), 3.7 + 0.2*cos(t), 'r'); TL2y=fill (6.8 + 0.2*sin(t), 3.7 + 0.2*cos(t), 'y'); TL2g=fill (7.3 + 0.2*sin(t), 3.7 + 0.2*cos(t), 'g');

% Traffic Light 3

TL3r=fill (6.3 + 0.2*sin(t), 6.3 + 0.2*cos(t), 'r'); TL3y=fill (6.3 + 0.2*sin(t), 6.8 + 0.2*cos(t), 'y'); TL3g=fill (6.3 + 0.2*sin(t), 7.3 + 0.2*cos(t), 'g');

% Traffic Light 4

TL4r=fill (3.7 + 0.2*sin(t), 6.3 + 0.2*cos(t), 'r'); TL4y=fill (3.2 + 0.2*sin(t), 6.3 + 0.2*cos(t), 'y'); TL4g=fill (2.7 + 0.2*sin(t), 6.3 + 0.2*cos(t), 'g');