LaneyWilliams Proj8 Report

Embed Size (px)

Citation preview

  • 8/8/2019 LaneyWilliams Proj8 Report

    1/25

    FPGA Traffic Light ControllerProject Report

    Laney Williams

    EENG 4990 - Project VIII

    Spring 2009

  • 8/8/2019 LaneyWilliams Proj8 Report

    2/25

    Table of Contents

    Abstract....................................................................................................................................3

    Problem Analysis.....................................................................................................................3

    Controller Design.....................................................................................................................6

    Concept and Specifications..........................................................................................7Implementation..........................................................................................................11

    Testing........................................................................................................................16

    Sensor Design........................................................................................................................19

    Concept and Specifications........................................................................................19

    Implementation..........................................................................................................20Testing........................................................................................................................20

    System Integration.................................................................................................................21

    Environmental and Safety Considerations.............................................................................23

    Conclusion.............................................................................................................................23

    References..............................................................................................................................23

    1

  • 8/8/2019 LaneyWilliams Proj8 Report

    3/25

    2

  • 8/8/2019 LaneyWilliams Proj8 Report

    4/25

    Abstract

    Traffic lights are meant to ease congestion, but in some situations they can be more of ahindrance than a help. The situation I am considering is road and highway: a seldom-used

    country road intersects a sometimes busy highway. In a normal sensor-actuated system, the

    highway light is usually green, and the road light is usually red. The highway light would turnred when a car approaches the intersection from the road and trips that sensor. However, this

    logic does not take into consideration approaching cars on the highway, which must make a

    quick stop from high speeds. I hope to solve this problem by creating a traffic light controllerwith sensors on the highway also integrated into the logic. This will move traffic light control

    towards look-ahead traffic-actuated control. The logic will be implemented in VHDL on an

    FPGA, with sensor circuits as input.

    Problem Analysis

    A country road intersects a sometimes busy highway between two cities. This road configurationcan be represented in the following figure.

    Cars on country road travel at lower speeds of about 30 MPH. Cars on highway travel at higher

    speeds about 60 MPH. Cars on road must cross highway safely.

    3

  • 8/8/2019 LaneyWilliams Proj8 Report

    5/25

    The road and highway intersection is represented in the following figure:

    The yellow boxes are the positions of the traffic lights; the blue diamonds are the positions of the

    sensors. This is a normal sensor-actuated traffic light design. In "The Design Methods

    Comparison Project, Bahill, et al. (1) proposed the following an algorithm for this traffic light:

    Normally, the highway light shall be green and the road light shall be red.

    When a sensor signals that a tractor is on the road, the highway light shall change to

    yellow.

    After ashort-time interval(STI, nominally 10 seconds) the highway light shall change to

    red and the road light shall change to green.

    The road light shall stay green until the tractor clears the sensor or after a long-time

    interval(LTI, nominally 50 seconds), whichever comes first.

    Then the road light shall become yellow.

    After a short time interval the road light shall become red and the highway light shallbecome green.

    The system shall stay in that state for a least a long time interval.

    After a long time interval the highway light shall be switched when the sensor detects atractor.

    4

  • 8/8/2019 LaneyWilliams Proj8 Report

    6/25

    Their state diagram for this algorithm follows:

    The above design could be improved. This logic does not take into consideration approachingcars on the highway, which must make a quick stop from high speeds. General traffic rules

    specify that cars on the road would yield to the highway, because the cars on the road at low

    speeds can stop more easily. However, this is not the case with this design. For instance, one caron the road, that has already stopped, could make several cars on the highway stop. This is

    illustrated in the following figure.

    This is inefficient and less safe. I hope to solve this problem by creating a traffic light controller

    with sensors on the highway also integrated into the logic.

    5

  • 8/8/2019 LaneyWilliams Proj8 Report

    7/25

    There are three new features which I have put in my design: look-ahead sensors (2, 3), green-

    light extension (2, 3), and an all-red-light phase (2). The sensors on the highway shall be a

    certain distance from the intersection (more on this in the next section). In this way the highwaysensors are look-ahead sensors. I have added an optional green-light time extension, so cars

    on highway can pass before the car on the road, having the car on the road yield to the cars on

    the highway. I also hope to make the traffic light control safer by adding an all-red-light phase,to protect other drivers from those who try to beat the yellow light, but dont quite make it.

    This will move traffic light control towards a safer look-ahead traffic-actuated control.

    6

  • 8/8/2019 LaneyWilliams Proj8 Report

    8/25

    Controller Design

    Concept and Specifications

    The road and highway intersection can be represented with this drawing (The yellow boxes are

    the positions of the traffic lights; the blue diamonds are the positions of the sensors.):

    My algorithm for the controller is as follows:

    Normally, the highway light shall be green and the road light shall be red.

    When the road sensor signals that a tractor is on the road the lights shall remain

    unchanged for at least a long time-interval (LTI, 10 seconds).

    After a LTI, the highway green light shall be extended for the time the highway sensor isactive plus a short-time interval (STI, 3 seconds), or for a very-long-time interval (VLTI, 30

    seconds) has passed, whichever comes first. Then the highway light shall change to yellow.

    After a STI, the highway light shall change to red.

    After a STI, the road shall become green.

    The road light shall stay green for the time the road sensor is active plus a STI or for a

    LTI, whichever comes first.

    Then the road light shall become yellow. After a STI the road light shall become red.

    After a STI the highway shall become green.

    The system shall stay in that state for a least a LTI.

    7

  • 8/8/2019 LaneyWilliams Proj8 Report

    9/25

    I drew a state diagram to represent my control algorithm in a way that can be easily synthesized

    in digital logic. My state diagram for this algorithm follows:

    This is a Moore state machine. The outputs are a function of the present state only and will

    continue until the machine switches to another state. I have given each state a name (in bold

    type on top of each state bubble) and the outputs are the traffic lights activated (on bottom ofeach bubble). The logic follows the arrow to the next state when the Boolean algebra expression

    next to that arrow is logic TRUE or 1.

    8

  • 8/8/2019 LaneyWilliams Proj8 Report

    10/25

    A block diagram for the state machine and its accompanying timers is shown in the following

    diagram.

    The timers deserve special attention, as they are internal signals. Internal timers have their ownlogic. Timers are started with individual internal start signal. Timers continue to count clock

    pulses as long as the start signal is 1. When timer has reached its maximum count it outputs a

    pulse (STI, LTI, and VLTI). In addition, sometimes the some timers can be interrupted. TheTransition, AllRed, and Normal states use uninterrupted timers. The Extend and

    Crossover states can interrupt and reset the STI timer. If a car triggers the sensor, it starts the

    STI timer. If another car triggers the sensor, the STI timer resets and starts again when that pulseends. This state only ends if STI and sensor signal are 0, or if a maximum time is reached.

    This is illustrated in the next two charts. The first chart shows the timing with no interrupting

    signals, and the second chart shows the timing with interrupting signals.

    9

  • 8/8/2019 LaneyWilliams Proj8 Report

    11/25

    These time intervals are chosen very specifically to conform to traffic theory concerning the

    look-ahead sensors on the highway. For sensor placement and traffic timing, one mustconsider the dilemma zone (3). In this zone, drivers have differing desire or ability to stop

    after seeing a yellow light. This zone is determined by probability of drivers stopping.

    Zimmerman and Bonneson (3), have determined that at 5 sec before intersection about 90% ofdrivers stop (a probable stop), and at 2 sec before intersection about 10% of drivers stop (a

    probable go). The delimma zone is about 3 seconds, which is why I chose this time for the

    STI. The dilemma zone is illustrated in the following figure.

    The rules for sensor placement are as follows:

    Road sensors shall be placed immediately before the stop-line. Highway sensors shall be placed immediately before the dilemma zone. [Distance from

    stop-line (ft) = 5 (s) Speed (ft/s)]

    1

  • 8/8/2019 LaneyWilliams Proj8 Report

    12/25

    These rules are illustrated in the following figure.

    Implementation

    The state diagram can be easily converted into digital logic equations and into VHDL code byusing enumerated types, a synchronous process, and a combinatorial process (4). In VHDL, you

    can create a special state type, and make all your state variables, that is, the names of the

    states, of that type.

    libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;

    entity trafficlight is Port ( sensorR : in STD_LOGIC;

    sensorH : in STD_LOGIC;Reset : in STD_LOGIC;Clock : inSTD_LOGIC;HwayGreen : out STD_LOGIC;HwayYellow : out STD_LOGIC;HwayRed : out STD_LOGIC;RoadGreen : out STD_LOGIC;RoadYellow : out STD_LOGIC;RoadRed : out STD_LOGIC);

    end trafficlight;

    architecture Behavioral of trafficlight is

    11

  • 8/8/2019 LaneyWilliams Proj8 Report

    13/25

    --enumerated state typetype traffic_type is ( Normal, Extend, Transition1, AllRed1, Crossover,Transition2, AllRed2 );--define state variablessignal current_state, next_state: traffic_type;--timer signals and constantssignal STI, LTI, VLTI, start_STI, start_LTI, start_VLTI, restart_STI:STD_LOGIC:= '0';constant clk_freq: integer:= 50000000; -- clock frequency (50MHz clock)constant Max_STI: integer:= 3*clk_freq; -- = # cycles in 3 sconstant Max_LTI: integer:= 10*clk_freq; -- = # cycles in 10 sconstant Max_VLTI: integer:= 30*clk_freq; -- = # cycles in 30 ssignal count_STI: integerrange 0 to Max_STI:= 0;signal count_LTI: integerrange 0 to Max_LTI:= 0;

    begin...

    In the synchronous process (which I called traffic_next_state), the current state changes to

    the next state at the next clock pulse, or resets to the normal state. The combinatorial process(which I called traffic_current_state) uses a case statement for each state, dictating the

    outputs and logic for state change. The combinatorial process is based on the current state, and

    dictates the next state.

    ...traffic_next_state: process (clock, reset)begin

    if (clock'event and clock = '1') thenif (Reset='1') then

    current_state

  • 8/8/2019 LaneyWilliams Proj8 Report

    14/25

    end if;-----Next-state logicif (LTI='1' AND sensorR='1') then

    next_state

  • 8/8/2019 LaneyWilliams Proj8 Report

    15/25

    RoadRed

  • 8/8/2019 LaneyWilliams Proj8 Report

    16/25

    RoadGreen

  • 8/8/2019 LaneyWilliams Proj8 Report

    17/25

    LTI

  • 8/8/2019 LaneyWilliams Proj8 Report

    18/25

    The second case I tested was that there is only a car on the road which moves before a LTI, or

    there could be many cars on the road spaced less than or equal to a STI apart all of which makethe crossover before a LTI.

    wait for 50 ns;in_sensorR

  • 8/8/2019 LaneyWilliams Proj8 Report

    19/25

    The fourth and final test is that there is a car on road, and many cars approaching on thehighway. To illustrate this, I have kept the highway value at 1 instead of using pulses.

    wait for 50 ns;in_sensorR

  • 8/8/2019 LaneyWilliams Proj8 Report

    20/25

    Sensor Design

    Concept and Specifications

    The sensor for the traffic light will have to sense both high-speed cars on the highway and

    stationary cars on the road. This is why I have chosen pressure sensors. A piezoelectric trafficsensor, such as the RoadTrax BL sensor from Measurement Specialties Inc., is embedded in the

    road and output a positive voltage when a vehicle drives over. The output voltage for a car is

    approximately 500 mV. The output can be upwards of 5 V for a large fully-loaded truck. The

    plot for the output voltages is shown in the following two graphs (the output for a car is on theleft, the output for a fully-loaded brick truck is on the right). (6)

    The output of this sensor should be amplified and fed into a comparator against a reference or

    threshold voltage.

    It is not feasible for me to test a sensor RoadTrax BL sensor because of size and cost restrictions.

    However, I can test a similar small-scale device, the FlexiForce A201 piezoresistive force sensor.The A201 varies its resistance in an inversely proportional relationship to applied force (7).

    When negative voltage is applied to the sensor in a negative feedback configuration, the output isanalogous to a piezoelectric sensor. This configuration is shown in the following figure (7).

    As with the RoadTrax BL sensor, the A201s output should be amplified and fed into a

    comparator against a reference or threshold voltage.

    1

  • 8/8/2019 LaneyWilliams Proj8 Report

    21/25

    Implementation

    I will be implementing the sensor design with the FlexiForce A201, as a small-scale model. The

    A201 datasheet has a suggested amplifier circuit (8). I changed the amplifier to a uA741 and

    added a voltage comparator. The output of the amplifier is given by: Vo = Vcc- * Rf/Rs. WithRf = 15k, when sensor is pressed the amplifiers output voltage is between 1 V and 4 V.

    Therefore, I configured the comparator so that if the amplifiers output is greater than 1 V, the

    output of the comparator goes logic high or Vcc, otherwise the output is logic low. The sensor

    circuit is shown in the following figure.

    Testing

    To test the small-scale sensor circuit, I pressed the force sensor, as Vout was attached to an

    oscilloscope. When the sensor does not experience any force the output voltage is about 80 mV.

    When the sensor is pressed the voltage makes a clean jump up to (then down from) 5 V. Theoutput is a digital signal with 80 mV (LOW) and 5 V (HIGH).

    2

  • 8/8/2019 LaneyWilliams Proj8 Report

    22/25

    System Integration

    In a real-life traffic light situation the system components would be organized as in the followingdiagram.

    The placement of components would be laid out as in the following diagram.

    2

  • 8/8/2019 LaneyWilliams Proj8 Report

    23/25

    However for testing purposes, the layout will be different. The VHDL code will be synthesized

    on the Spartan-3 XC3S200 FPGA. The sensor will be synthesized from its discrete componentson a breadboard. I should be able to interface the sensors with the FPGA through the expansion

    connector pins.

    Environmental and Safety Considerations

    I have integrated both environmental and safety considerations into my design, in accordance

    with IEEE ethics: making decisions consistent with the safety, health and welfare of the public.

    2

  • 8/8/2019 LaneyWilliams Proj8 Report

    24/25

    In order to minimize energy consumption, the system will use LEDs instead of regular

    incandescent bulbs. LEDs use 4 to 18 watts compared to 150 to 69 watt incandescent bulbs (9),

    increasing efficiency. LEDs also last 10 times longer than incandescent bulbs (9), decreasingreplacement waste. The design is also safer than the old semi-traffic-actuated design. The

    green-light-extension phase with "look-ahead" sensors is safer. A study (10) shows a 35%

    reduction in crash rate for intersections with approach speeds of 55 mph over unmodifiedintersections. Additionally, the all-red-light phase is safer. A study (10) shows a 30% average

    reduction in all traffic accidents over unmodified intersections. However, there are still dangers

    which I must state, in accordance with IEEE ethics: disclose promptly factors that mightendanger the public or the environment. There are two worst-case scenarios: a glitch causes all-

    green lights, and a power outage causes no lights. A possible solution to both scenarios is to

    install separate circuitry, on a generator, to monitor for these conditions and over-ride with

    blinking-lights.

    Conclusion

    In conclusion, my design effectively improves upon the basic sensor-actuated design for this type

    of intersection. My design has sensor input for high-speed cars on the highway, using look-

    ahead sensors. This design allows cars on the road to yield to the cars on the highway, by

    adding a green-light extension. Rapidly approaching cars on the highway will not have to stopfor one car on the road that has just pulled up to the traffic light. My design also adds an all-red-

    light phase to protect drivers against red-light runners. A piezoresistive sensor can be used as a

    piezoelectric sensor, if negative voltage is applied to the sensor in a negative feedbackconfiguration. The output voltage of the piezoelectric or piezoresistive force sensors can be

    easily converted to digital by a comparator for input into the controller. The controller andsensors could easily be implemented in a real-life intersection.

    References

    (1) Bahill, A. Terry, and Mack Alford, K. Bharathan, John Clymer, Douglas L. Dean, Jeremy

    Duke, Greg Hill, Ed LaBudde, Eric Taipale, and A. Wayne Wymore. "The Design Methods

    Comparison Project." IEEE Transactions on Systems, Man, and Cybernetics, Part C:

    Applications and Reviews, Vol. 28, No. 1, pp. 80-103. February 1998.

    (2) Van Katwijk, Ronald. Multi-Agent Look-Ahead Traffic-Adaptive Control. TRAIL ThesisSeries, The Netherlands TRAIL Research School, January 2008.

    (3) Zimmerman, K., and J. Bonneson. Detection-Control System for Rural SignalizedIntersections. Texas Transportation Institute, Texas A&M University. 1 December 2000.

    (4) Traylor, Roger L. State Machines in VHDL.

    http://web.engr.oregonstate.edu/~traylor/ece474/new_vhdl_pdfs/state_machines_in_vhdl.pdf

    2

    http://web.engr.oregonstate.edu/~traylor/ece474/new_vhdl_pdfs/state_machines_in_vhdl.pdfhttp://web.engr.oregonstate.edu/~traylor/ece474/new_vhdl_pdfs/state_machines_in_vhdl.pdf
  • 8/8/2019 LaneyWilliams Proj8 Report

    25/25

    July 2004.

    (5) Free Information Society. 25.175MHz to 1Hz Clock Divider in VHDL.http://www.freeinfosociety.com/site.php?postnum=521

    (6) Measurement Specialties Inc.http://www.meas-spec.com/downloads/RoadTrax_BL.pdf

    (7) Tekscan Inc., FlexiForce Force Sensors. http://www.tekscan.com/flexiforce/flexiforce.html

    (8) Tekscan Inc., FlexiForce A201 Datasheet.http://www.tekscan.com/pdfs/DatasheetA201.pdf

    (9) U.S. Environmental Protection Agency. Energy Efficiency Sector: Led Traffic Signals.

    http://epa.gov/climatechange/wycd/downloads/CO_LED.pdf January 2000.

    (10) Agent, Kenith, and Nikiforos Stamatiadis, Samantha Jones. Development of Accident

    Reduction Factors. Kentucky Transportation Center, College of Engineering, University of

    Kentucky. June 1996.

    http://www.freeinfosociety.com/site.php?postnum=521http://www.meas-spec.com/downloads/RoadTrax_BL.pdfhttp://www.meas-spec.com/downloads/RoadTrax_BL.pdfhttp://www.tekscan.com/flexiforce/flexiforce.htmlhttp://www.tekscan.com/pdfs/DatasheetA201.pdfhttp://www.tekscan.com/pdfs/DatasheetA201.pdfhttp://epa.gov/climatechange/wycd/downloads/CO_LED.pdfhttp://www.freeinfosociety.com/site.php?postnum=521http://www.meas-spec.com/downloads/RoadTrax_BL.pdfhttp://www.tekscan.com/flexiforce/flexiforce.htmlhttp://www.tekscan.com/pdfs/DatasheetA201.pdfhttp://epa.gov/climatechange/wycd/downloads/CO_LED.pdf