Loading

Kategory:

Traffic Light Controller

Bookmark and Share
Overview
When I was in college our junior year lab included a project to construct a simple traffic light controller using only digital logic. This means no microcontroller, no 'if' statements nothing but pure hardcore logic. The intent of the lab was to implement a state machine in a realistic application. This article is a collection of pictures and a very general explanation of my solution, plus a VHDL implementation of it. NOTE: This is not a complete write up, it's mostly what I remember and found on my drives.

Scenario
A town needs to build an intersection between a heavily traveled East-West highway and a North-South country road. Since there are people in the town, the traffic light should have a pedestrian button which stops both roads for four (4) seconds and allow people to cross. When there is a car on the country road the highway should wait for five (5) seconds before turning red. The light for the country road should then be green for nine (9) seconds before going back to red. The highway is important to the area so the traffic lights should always return to green on the highway. The highway and country roads must have red, green and yellow lights, the pedestrian cross may only red and green.

The lab required a prototype using LEDs and seven-segment displays for the countdowns. The system could only use discrete digital logic chips and passive components.

Solution
The solution here uses two inputs, one for a car on the North-South road and one for the pedestrian. Since the default for the scenario is to enable the East-West road, no input is needed. If you make the state machine diagram for the inputs, you will see you have four possible outputs:



The equations at the bottom were determined using a karnal map. After the equations were determined it's just a matter of wiring up the logic chips to represent the equations



The entire circuit is clocked using a 32.786KHz crystal divided down to 1 hertz for the rest of the circuit. This one second clock controls a counting and display circuit designed to display the time remaining for each light in the system. This counting circuit uses countdown timers which assert a signal if the count reaches zero, this signal is then used as the control back to the state machine. The display circuit was also the control of the yellow lights in the system. When a countdown reached three seconds prior to the light turning red, a multiplexer chip switched disabled green and enabled yellow.



Aftermath:


VHDL:
Since most digital logic systems rely on simple boolean algebra they are really easy to port over to a hardware language like VHDL. A year after the traffic light controller project I created a VHDL version which runs on a Xilinx CoolRunner II development board. Attached to the dev board was a Digilent DIO1 board with LEDs, switches and four seven-segment displays. Three of the four seven-segment displays are used to count down the different times and the 8 LED bank is nicely R,Y,G,R,Y,G,R,R. Thus the upper 3 LEDs are the RYG for the East-West road, the next are for the North-South road and the final two red LEDs are for the pedestrian (we just pretend the last one is green). The project was perfect for the chip, using only 26% of the resources.
Thanks for reading: Traffic Light Controller
Related Posts Plugin for WordPress, Blogger...