You are on page 1of 6

Final Project Report: Simple Traffic Light Controller

Author: Aziz Yuldashev


Report Due Date: 03/16/11
Course: ECEGR 401- VHDL
Instructor: Dr. Margarita Takach
Department of Electrical and Computer Engineering
SeattleUniversity

Objective

Inthisprojectthemainobjectivewastodesignasimpletrafficlightcontrollerand

illustrateitsoperationbyprogrammingAlteraDE2Cyncloneserieseducationboard,which
displayedtrafficlightsonascreenconnectedthoughaserialoutput.

EquipmentandTools

Inthisprojectthefollowingequipmentandtoolswereused:
Tools:

VHDL

QuartusIIcompilerdesignedbyAltera

Equipment:

AlteraDE2DevelopmentandEducationBoard

NeccomputerscreenofMultiSyncXV15+series

EquipmentSetUp

Thediagrambelowillustratesthesetupoftheequipmentusedinthisproject:

SerialOutputtoScreen

Screen

AlteraDE2
EducationBoard

NecMuliSyncXV15+

ComputerWith

Power

QuartusSiftware

DesignProcedure

Theideawastoimplementatrafficlightcontrollerforanintersectionwitheightlights.
Eachstreethasonelanewhichthendividesintotwolanes:onetoturnleftonlyandtheother
togostraightortoturnright,attheintersection.Oneofthestreetsisamainstreet,meaning
thatthelightstogostraightarealwaysgreenunlesstherearecarsontheintersectingstreetor
acaronthemainstreetappearsontheleftonlylane.Thediagrambelowbestillustratesthis
picture:
N

Sensors

TrafficLights

MainStreet

Sensor

Asshownabove,thestreetintersectingthemainstreethastwosensorsoneach
direction.Onsensorforaleftturnandonesensorforarightturncontrolthelightstogether
withaleftturnsensoronthemainstreetforeachdirection.Thusthereareeighttrafficlights,
fourforleftturnoneachstreetforeachdirectionandsixsensorstocontroltheselights.
LogicofTheTrafficLightController
Thelogicofthetrafficlightcontrollerisverysimple.Allithastodoisswitchlights
accordingtotheloworhighsignalcomingfromsensors.Theinitialstateofthecontrolisthat
thestraightlightsonthemainstreetarealwaysgreenunlessthereisacarontheintersecting
streettryingtostraightorturningleft.Soifthereisacargoingstraightontheintersecting
street,thenthestraightlightsonthemainstreetwilltransitiontoyellowandthenredafter

waitingforfortysecondsandthestraightlightsontheintersectingstreetforeachdirectionwill
turngreenwhileallotherlightsremainred.Theafterwaitingforfortysecondsthelightstraight
lightonthemainstreetwillturngreenafterthestraightlightontheintersectingstreet
transitionsfromgreentoyellowandthentored.So,thesamelogicappliestoothercases.
Beforeturningthislogicintocodeitwasidealandhelpfultohaveastatediagram
describingeachcasesforthetrafficlightcontroller.
S4

Carsonthemain
S4
WGL|EGL
Streetturningleft
WGL|EGL

andcarsonthe
40s
otherstreetgoing
SGST|NGST

straightandturning
40s
Carsonthemain
leftafter40s
SGL|NGL
Streetturningleft

after40s

After40s

S3
SGST|NGST
40s
SGL|NGL

After40s

Carsontheintersectingstreet
goingstraightandturningleft
after40s

Carontheintersectingstreet

turningleftandafter40s

S0
WGST|EGST

S2
SGL|NGL

After40s

Carontheintersectingstreet
goingstraightandafter40s

S1
SGST|NGST

Thestatediagramaboveshowsthegenerallogicofthecontroller.SoatS0theonly
lightsthataregreenareWestGreenStraight(WGST)lightsandEastGreenStraight(EGST)
lights.Notethatthisstatediagramonlyshowsthelightsthataregreen,allotherlightsarered.
Inadditioneachstatehassubstatesthatcontrolthetimingofthetransitions.Whenacarstops
ontheintersectingstreetonalanegoingstraight,thesensortriggersandthecounterstarts
counting.Whenthecountreaches40s,thestatetransferstoS1andthelightsonthemain
streettransitionfromgreentoredandthelightsgoingstraightontheintersectingstreet
becomegreenthusitisnotedasSouthGreenStraight(SGST)andNorthGreenStraight(NGST)
inthestatediagram.Whenthelighthitsgreenontheintersectingstreet,thecounterrefreshes
andstartscountingfromzero.Whenthecountreaches40sthestatetransitionstoS0.When

therearetwocarsontheintersectingstreet,onegoingstraightandoneturningleftthenthe
newstatebecomesS3.Here,carsgoingstraightwillbepassedfirstandthenthecarsturning
leftwillgoafter40s,thusthisphenomenonisnotedasSouthGreenStraight(SGST)andNorth
GreenStraight(NGST),thenwaitfor40s(40s)inthestatediagram,thenturnthesouthand
northstraightlightsredandturnthesouthandnorthleftturnlightsgreenthusnotedasSouth
GreenLeft(SGL)andNorthGreenLeft(NGL)inthestatediagram.Sotherestofthelogicis
similartowhathasbeenexplainedabove.

VHDLCode
TwoVHDLprogramswereusedinthisproject.OnenamedVGA_Control.Thisprogramis
theoutputprogramthatcontrolsthescreen.Thesecondprogramcalledmake_imageisan
inputprogramtotheVGA_Controlprogram.Inthisprojectwehavemodifiedthemake_image
programprovidedtousbyDr.M.Takach.
BothVHDLcodesareattachedseparatelywiththesynthesisanalysisprovidedbytheRTL
viewerofQuartusII.

ControlSwitches
SixswitchesontheAlteraboardactassensorsforthisproject.Herearetheswitch
assignments:
SensoronthewestsideofmainstreetturningleftPIN_N26(SW2)
SensorontheeastsideofmainstreetturningleftPIN_N25(SW1)
SensoronthenorthsideofintersectingstreetgoingstraightPIN_V2(SW15)
SensoronthenorthsideofintersectingstreetturningleftPIN_V1(SW14)

SensoronthesouthsideofintersectingstreetgoingstraightPIN_U4(SW17)
SensoronthesouthsideofintersectingstreetturningleftPIN_U3(SW16)

Conclusions
InthisprojectwehavedesignedatrafficlightcontrollerusingVHDL.Theprocesswas
longandsomewhatpainfulandstressful,howevertwoweeksofworkpaidofattheendwhen
weweresuccessfullyabletoimplementthestatemachineandoutputtheresultsonascreen.