1 / 14

第十四讲 综合设计实例分析一 交通灯控制电路设计

第十四讲 综合设计实例分析一 交通灯控制电路设计. 主讲人:方跃春 长沙民政学院电子信息工程系. 交通灯控制电路设计. 1 、功能及要求 基本功能及要求: 该控制电路用于主、支道交通路口,要求优先保证主干道畅通,红、绿灯时间分配如下: 主绿灯亮、支红灯亮 1 分钟 主黄灯闪、支黄灯闪 4 秒钟 主红灯亮、支绿灯亮 30 秒钟 主黄灯闪、支黄灯闪 4 秒钟 …… 进阶功能及要求: 倒计时显示。. 1HZ. 秒时钟产生. 循环计时. CLK. 主 支. 红绿灯控制.

elsie
Download Presentation

第十四讲 综合设计实例分析一 交通灯控制电路设计

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第十四讲 综合设计实例分析一 交通灯控制电路设计 主讲人:方跃春 长沙民政学院电子信息工程系

  2. 交通灯控制电路设计 1、功能及要求 基本功能及要求:该控制电路用于主、支道交通路口,要求优先保证主干道畅通,红、绿灯时间分配如下: 主绿灯亮、支红灯亮 1分钟 主黄灯闪、支黄灯闪 4秒钟 主红灯亮、支绿灯亮 30秒钟 主黄灯闪、支黄灯闪 4秒钟 …… 进阶功能及要求: 倒计时显示。

  3. 1HZ 秒时钟产生 循环计时 CLK 主 支 红绿灯控制 倒计时译码及显示驱动 SEL[1..0] DIG[6..0] Q[6..0] 倒计时 交通灯控制电路设计 2、引脚定义及原理框图

  4. 交通灯控制电路设计 基准时钟脉冲经秒时钟产生模块产生1HZ方波,作为循环计时模块及倒计时模块的计时脉冲。循环计时模块从0~98秒计数,产生红绿灯控制时序。红绿灯控制控制模块产生红绿灯控制信号。倒计时模块进行时间倒计时,再通过倒计时译码及显示驱动模块驱动数码管显示。

  5. 交通灯控制电路设计 顶层电路原理图:

  6. 交通灯控制电路设计 模块程序----1HZ产生模块 LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; ENTITY clk_1hz_v2 IS PORT(CLKI : IN STD_LOGIC; CLK_1hz : OUT STD_LOGIC; CLK_2hz : OUT STD_LOGIC); END clk_1hz_v2 ; ARCHITECTURE a OF clk_1hz_v2 IS SIGNAL cou : STD_LOGIC_VECTOR(8 DOWNTO 0); BEGIN PROCESS(clki) BEGIN

  7. 交通灯控制电路设计 IF (clki'event and clki='1') THEN cou <= cou+1; END IF; END PROCESS; CLK_1hz <= cou(8); CLK_2hz <= cou(7); END a;

  8. 交通灯控制电路设计 模块程序---- 状态产生模块 LIBRARY IEEE; USE IEEE.std_logic_1164.all; ENTITY count IS PORT( CLK_1hz : IN STD_LOGIC; Contr : OUT STD_LOGIC_VECTOR(1 downto 0)); END count; ARCHITECTURE a OF count IS BEGIN PROCESS (Clk_1hz) VARIABLE temp :INTEGER RANGE 0 TO 97; BEGIN IF (Clk_1hz'event AND Clk_1hz='1') THEN

  9. 交通灯控制电路设计 if(temp=97) then temp:=0; else temp:= temp+1; end if; END IF; IF(temp<60) then contr<="00"; elsif(temp<64) then contr<="01"; elsif(temp<94) then contr<="10"; else contr<="11"; end if; END PROCESS ; END a;

  10. 交通灯控制电路设计 模块程序----红绿灯控制模块 LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY LIGHT IS PORT(contr :IN STD_LOGIC_vector(1 downto 0); clk_2hz : IN STD_LOGIC; r1,r2,g1,g2,y1,y2 :OUT STD_LOGIC); END LIGHT; ARCHITECTURE a OF LIGHT IS BEGIN PROCESS(contr) BEGIN

  11. 交通灯控制电路设计 IF (contr="00")THEN r1<='0'; g1<='1'; y1<='0'; r2<='1'; g2<='0'; y2<='0'; elsif( contr="01" ) THEN r1<='0'; g1<='0'; y1<=clk_2hz; r2<='0'; g2<='0'; y2<=clk_2hz; elsif(contr="10") then r1<='1'; g1<='0'; y1<='0'; r2<='0'; g2<='1'; y2<='0'; else r1<='0'; g1<='0'; y1<=clk_2hz; r2<='0'; g2<='0'; y2<=clk_2hz; END IF; END PROCESS; END a;

  12. 交通灯控制电路设计 模块程序----倒计时模块 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity daojishi is port(clk_1hz:in std_logic; contr:in std_logic_vector(1 downto 0); time:out std_logic_vector(5 downto 0)); end daojishi; architecture a of daojishi is begin process(clk_1hz) variable temp:integer range 0 to 59; begin

  13. 交通灯控制电路设计 if(clk_1hz'event and clk_1hz='1')then if(contr="00")then if(temp=0) then temp:=59; else temp:=temp-1; end if; elsif(contr="01")then if(temp=0) then temp:=3; else temp:=temp-1; end if; elsif(contr="10")then

  14. 交通灯控制电路设计 if(temp=0) then temp:=29; else temp:=temp-1; end if; else if(temp=0) then temp:=3; else temp:=temp-1; end if; end if; end if; time<=conv_std_logic_vector(temp,6); end process; end a;

More Related