You are on page 1of 9

NATIONAL INSTITUTE OF TECHNOLOGY, DELHI

Traffic Light Controller


(Single Way)
Digital System Design Project
Nikhil Kapila (141200004)
Harshit Kumar (141200005)

11/7/2016

ECE – Semester 5 (2016-2017)


Page 2 of 9

Table Of Contents

S.No. Title Description

Introduction
Traffic Light Controller  Traffic Light Controller
1. (TLC, Single Way)

 VHDL Code
2. Design Procedure  Logic Applied
 Explanation of Output

3. Conclusion & Result  Conclusion & Result


Page 3 of 9

Traffic Light Controller


Traffic signals are used to control the flow of vehicles.
In recent years, the need of transportation has gained immense importance in every field. This has
increased the number of vehicles on the road.
Due to this, traffic jams & road accidents are very common nowadays.
Traffic Light Controllers which control the flow of cars on the road by controlling traffic signals are
required.

A variety of different control systems are used to accomplish this, ranging from simple clockwork
mechanisms to sophisticated computerized control and coordination systems that self-adjust to
minimize delay to people using the road.

Traffic lights were first invented in the year 1868 at London’s House of Commons where traffic light
signals were placed at intersections of George and Bridge Street. Later the traffic lights were
developed in the year 1914 by an American Traffic Signal Company, which fixed green and red lights
at corners of the 105th street and Euclid Avenue in Cleveland, Ohio. During this period traffic lights
were controlled either by timing or by switching manually.

Traffic lights are also named as stoplights, road traffic lamps, traffic signals, stop-and-go lights which
are signalling devices placed at road crossings, everyday pedestrian crossings and other locations to
control competing flows of traffic. Traffic lights have been fixed all over the world in many cities.
Traffic light control assigns a right way to the road users by using lights in normal colours (red –
amber/yellow – green). Traffic light control system uses a worldwide colour code (a specific colour
order to enable colour recognition for those who are colour blind).

A Traffic Light Controller made using a seven segment display, a counter display, 3 LEDs & the 8051
microcontroller. (timer approach)
Page 4 of 9

VHDL Code
library IEEE;

use IEEE.STD_LOGIC_1164.all;

entity TLC_sensor is

port(

clk : in STD_LOGIC;

sensor : in STD_LOGIC;

r : out STD_LOGIC;

y : out STD_LOGIC;

g : out STD_LOGIC

);

end TLC_sensor;

architecture TLC_sensor_arc of TLC_sensor is

type color is (red,yellow,green);

signal p_state : color;

signal n_state : color;

begin

present_state : process (clk) is

begin

if (rising_edge (clk)) then

p_state <= n_state;

end if;

end process present_state ;

next_state : process (p_state, sensor) is

begin

case (p_state) is
Page 5 of 9

when red =>

if (sensor = '1') then

n_state <= green;

else

n_state <= red;

end if;

r <= '1';

y <= '0';

g <= '0';

when green =>

if (sensor='1') then

n_state <= green;

else

n_state <= yellow;

end if;

r <= '0';

y <= '0';

g <= '1';

when yellow =>

n_state <= red ;

r <= '0';

y <= '1';

g <= '0';

end case;

end process next_state;

end TLC_sensor_arc;
Page 6 of 9

Logic Applied
There are many ways to design the TLC (single way). However, we use the sensor approach.
Instead of using a timer or a counter approach, we used a 3rd approach called the Sensor approach.
We assume that the traffic light has a sensor equipped with it.
If the sensor senses a car at the junction, it will produce an output ‘1’.

The output ‘1’ is then fed into the Traffic Light Controller (Microcontroller) which runs to go to the
next state corresponding to the current state.From this, we learn that the micro-controller remains at
GREEN until the sensor gives a feedback of ‘1’.

Here is a brief working of how our code works:

 If the sensor senses a car on the road and produces a ‘1’ output which is fed into the
microcontroller.
 The microcontroller now turned ‘ON’ and having the default colour RED which is its present
state, now turns to its next state which is GREEN (since the sensor still gives an output of
‘1’).
 The sensor still giving a ‘1’ feedback keeps the output of the microcontroller at GREEN.
 Once all the cars have crossed the junction, the sensor gives an output of ‘0’, therefore until
the sensor gives an output ‘0’ the microcontroller gives an output of YELLOW.
 At the next CLK, the state after yellow gets assigned to RED.
 The sensor now remains in its neutral state checking for cars at the junction until a car arrives
& the RED colour is emitted from the LED.
Page 7 of 9

Explanation of Output

The default output state of the traffic light (RED).

We can see that the output remains GREEN for a constant ‘1’ at the sensor.
Page 8 of 9

When the sensor gives ‘0’, the output changes from green to YELLOW & then to RED.
After that, the output of the traffic light is constant at RED.

On changing the value of sensor to ‘1’ again, the output changes to GREEN.

Therefore, the working of our code has been verified and it also works according to the state
diagram presented above.
Page 9 of 9

Conclusion & Result


Result
The simulation has been performed and has been check thoroughly by the state diagram & through the
simulation outputs.

Conclusion & Drawbacks


 One advantage of my approach is that it is very easy to implement.

 Even though my code works perfectly, it is heavily reliant on the sensor in the hardware
implementation.

 If the sensor somehow fails, it could cause way too many problems like accidents, traffic
jams. etc. However, we can make a small fail-check system which can check if the sensor is
giving an output at every positive edge.
If the feedback system detects no output, it will create a short circuit towards the ground
which will switch off the traffic light.

 The frequent checks with the sensor CAN reduce the speed of operation of the circuit.

 A better approach would be using the timer approach with a 7 segment display, it will result
in lesser errors compare to our approach.