Search This Blog

Saturday, July 27, 2013

Sensor Based Traffic Light Controller using FSM Technique (VHDL Code).






Sensor Based Traffic Light Controller using FSM Technique -


Output Waveform :   Sensor Based Single Way Traffic Light Controller.



VHDL Code-



-------------------------------------------------------------------------------
--
-- Title       : TLC_sensor
-- Design      : vhdl_upload2
-- Author      : Naresh Singh Dobal
-- Company     : nsdobal@gmail.com
-- VHDL Programs &  Exercise with Naresh Singh Dobal.
--
--
-------------------------------------------------------------------------------
--
-- File        : Sensor based single way traffic light controller.vhd



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
            when red =>
            n_state <= green;
            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;

1 comment:

  1. hi, I want to quest you another thing. Using FPGA modelsim programm,
    Traffic Signal Controller Design
    - Design of Traffic Signal Controller with intersection of North and South (NS) and East (EW)
    - always green signal when there is no vehicle on the EW road because NS road is leading to heavy traffic flow
    Maintenance
    - Signal change when vehicles are on the EW road
    - Signal lamps : Green, yellow and red
    - NS Road Signal Time : Green (6 sec) - > Yellow (2 sec) - > Red
    - EW Road Signal Time : Green (3 sec) - > Amber (2 sec) - > Red
    - Designed as Moore or Mealy

    Can you solve this question?

    ReplyDelete