版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、数字电路综合实验报告学院:信息与通信工程 专业:信息工程 班级:2013211125 基于CPDL的简易洗衣机控制器的设计与实现一:设计课题的任务要求基本要求: 1、 洗衣机的工作步骤为洗涤、漂洗和脱水三个过程,工作时间分别为:洗涤 30秒(进水5秒,洗衣15秒,排水 5秒,甩干 5秒),漂洗 25秒(进水 5秒,漂洗 10秒,排水5秒,甩干 5秒),脱水 15秒(排水5秒,甩干 10秒); 2、 用一个按键实现洗衣程序的手动选择:A、单洗涤;B、单漂洗;C、单脱D、漂洗和脱水;E、洗涤、漂洗和脱水全过程; 3、 用发光二极管显示洗衣机的工作状态(洗衣、漂洗和脱水),并倒计时显示每个状态的工作
2、时间,全部过程结束后,应有声音提示使用者,并保持在停止状态,直至再次开始; 4、 用点阵动画显示洗衣机工作过程中进水、波轮或滚筒转动、排水和甩干等的工作情况,四种工作情况的动画显示要有区别且尽可能的形象。 5、 用一个按键实现暂停洗衣和继续洗衣的控制,暂停后继续洗衣应回到暂停之前保留的状态;提高要求: 1、 三个过程的时间有多个选项供使用者选择。 2、 可以预约洗衣时间。 3、 自拟其它功能。二:系统设计(一)设计思路本题目较复杂的地方是状态太多,而且状态中还嵌套着状态,于是我选择了分模块写代码然后顶层用原件图连接起来的设计方法。根据实验要求,首先要通过一个经过防抖按键来实现模式的选择,这里我
3、通过记录输入时钟上升沿的个数来选择好不同的模式,同时设置好不同模式对应的总时间,状态转移时间,LED初始值等。然后在检测到确定按键产生的信号后,将这些选择好的信息传入到中心控制器中。在中心控制器中由开始/暂停键来控制程序的进行,在开始状态下,时间会递减,并可以判断是否进行状态转换而转换到下一个状态(洗涤,漂洗,脱水),同时将变化的时间传入到时间处理模块和动画转换模块,前者将输入的时间提取成个位和十位,然后输出到数码管控制模块进行显示。后者通过与选择模式的结合,可以决定当前模式与时间对应的动画,将决定动画的代码传入到动画模块,即可以通过点阵显示不同的动画。当时间减少到0时,中心控制器还会输出一个
4、蜂鸣器报警的信号来控制报警。所有进程执行完毕后,各项数据会进行清零返回,等待下一次的使用。由上面的设计思路可以总结出一共有以下的模块:分频模块、防抖模块、按键(模式选择,确定,开始/暂停)模块、中心控制模块、时间处理模块、数码管显示模块、数码管选通模块、动画控制模块、动画显示模块、报警模块。在下文中有对每个模块的功能介绍,代码分析以及仿真波形的分析。(二)总体框图上文所述的各种模块之间的连接如图所示:说明:其中动画模块,数码管模块等还可以细分,在下文中也有着详细的介绍以及相关代码和仿真分析。(三)状态转移图111由于洗衣的五种模式之间存在着相互的联系,我们可以用状态转移图来表示这五种状态在选择
5、时的转换关系:001110000010100说明:001:单洗涤 010:单漂洗 100:单脱水 110:漂洗+脱水 111:洗涤+漂洗+脱水 000:结束(4) 控制流程图 开始模式选择 确定? 否 是 开始? 否数码管,led,点阵动画显示 是 倒计时 暂停? 为0? 否 否 是 是 暂停 结束并报警 开始?否 是三:分块设计代码及仿真分析(一)分频模块 1:模块功能 此模块对外部输入的25MHZ时钟进行三级分频。第一级分为600HZ,用于点阵和数码管的扫描,第二级为100HZ,用于防抖模块的输入信号,第三级为1HZ,用于时间控制和动画控制。 2:代码分析(以三级分频为例子)library
6、 ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity div is port( clk:in std_logic; -输100HZ时钟 clkout:out std_logic -分频后的1HZ时钟 );end div;architecture a of div is signal temp_clk:std_logic; signal tmp:integer range 0 to 49;begin process(clk) begin if(clk'event and clk='1
7、9;) then if tmp=49 then tmp<=0; temp_clk<=not temp_clk; else tmp<=tmp+1; end if; end if;end process; clkout<=temp_clk;end a;3:仿真波形与分析由波形图可见,输入100个时钟,输出一个时钟,实现了对输入时钟的100分频。 (二)防抖模块 1:模块功能 由于按键在有反应时间,有抖动,可能会造成你按一次产生多个脉冲的情况从而影响程序进程。防抖可以消除抖动,使得你按一次键只产生一个时钟信号。 2:代码分析library ieee;use ieee.std_
8、logic_1164.all;entity fangdou is port(clk:in std_logic; -100HZ时钟信号 key:in std_logic; -按键输入 key_out:out std_logic); -输出end fangdou;architecture a of fangdou is signal resetmp1,resetmp2:std_logic;beginprocess(clk)beginif(clk'event and clk='0') then resetmp2<=resetmp1; resetmp1<=key;e
9、nd if;end process; key_out<=clk and resetmp1 and (not resetmp2); -消除抖动end a; 3:仿真波形与分析 由图可知,防抖程序消除了一些毛刺,使输出信号变得稳定。(三)按键模块 1:模块功能 此模块有三个部分,一个是模式选择按钮,产生相应的模式信号。一个是确定按钮,通过按键来改变输出的高低电平,还有一个是开始/暂停按钮,产生控制时间变化的信号,这两者都采用循环计数的方式来控制信号。 2:代码分析library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsig
10、ned;entity modeselect is port( mode_in:in std_logic; -模式选择信号 start:in std_logic; -开始/暂停信号 datain:in std_logic; -确定信号 mode_out:out std_logic_vector(2 downto 0); -模式输出 led_out:out std_logic_vector(2 downto 0); -LED信号 timecount:out integer range 0 to 70; -总时间 temp:out integer range 0 to 40; -转移时间 st_ou
11、t:out std_logic; -开始/确定输出 data_out:out std_logic -确定信号输出 );end modeselect; architecture a of modeselect is signal modetmp:std_logic_vector(2 downto 0); signal state:std_logic_vector(2 downto 0); begin p1: process(mode_in) -模式转换 begin if(mode_in'event and mode_in='1') then case modetmp is
12、 when "000"=>modetmp<="001" when "001"=>modetmp<="010" when "010"=>modetmp<="100" when "100"=>modetmp<="110" when "110"=>modetmp<="111" when others=>modetmp<="
13、000" end case; mode_out<=modetmp; end if; mode_out<=modetmp; state<=modetmp; case state is -设置时间等信号 when "000"=>timecount<=0;temp<=0;led_out<="000" when "001"=>timecount<=30;temp<=0;led_out<="001" when "010"=>
14、timecount<=25;temp<=0;led_out<="010" when "100"=>timecount<=15;temp<=0;led_out<="100" when "110"=>timecount<=40;temp<=15;led_out<="010" when "111"=>timecount<=70;temp<=40;led_out<="001"
15、 when others=>timecount<=0;temp<=0;led_out<="000" end case; end process; p2:process(start) -开始/暂停信号 variable sout:integer range 0 to 1; begin if(start'event and start='1') then if(sout=0) then sout:=sout+1; else sout:=0; end if; if(sout=0) then st_out<='0'
16、; else st_out<='1' end if; end if; end process; p3:process(datain) -确定信号 variable dout:integer range 0 to 1; begin if(datain'event and datain='1') then if(dout=0) then dout:=dout+1; else dout:=0; end if; if(dout=0) then data_out<='0' else data_out<='1' en
17、d if; end if; end process; end ; 3:仿真波形与分析 由图可知,在选择模式2(按两次键,单漂洗)的情况下,会对应输出LED信号为010,模式输出信号为010,总时间为25,时间转移信号为0(即不转移)。确定键按一下后能够输出一个高电平,而暂停/开始键按一下输出高电平,再按一下输出变成低电平。(四)中心控制模块 1:模块功能 此模块为此工程最为关键的部分,它通过控制时间的倒数间接的控制了数码管显示,点阵显示,LED显示,以及蜂鸣器报警。此部分通过确定键和开始/暂停键来实现对时间的控制。 2:代码分析library ieee;use ieee.std_logic_1
18、164.all;use ieee.std_logic_unsigned;entity controlcenter isport( clk:in std_logic; -1HZ扫描频率 switch:in std_logic; start:in std_logic; mode_in:in std_logic_vector(2 downto 0); led_in:in std_logic_vector(2 downto 0); timecount:in integer range 0 to 70; temp:in integer range 0 to 40; led_out:out std_log
19、ic_vector(2 downto 0); -输出LED信号 alarm:out std_logic; -输出蜂鸣器信号 timeout:out integer range 0 to 70 -输出时间 );end controlcenter;architecture a of controlcenter is signal mode2 :std_logic_vector(2 downto 0); signal time2:integer range 0 to 70; signal temp2:integer range 0 to 40; signal led2:std_logic_vecto
20、r(2 downto 0); begin process(clk) begin if(clk'event and clk='1') then if(switch ='1') then -确定信号为1,预制信号进入系统 mode2<=mode_in; time2<=timecount; temp2<=temp; led2<=led_in; end if; if(start='1') then -开始 if(time2/=0) then -时间不为0 time2<=time2-1; -时间-1 timeout&l
21、t;=time2; alarm<='0' led_out<=led2; elsif(time2=0) then -时间为0,LED灭,蜂鸣器响 alarm<='1' timeout<=time2; led_out<="000" end if; if(time2=temp2) then -时间=temp,转换状态,重置temp,led case mode2 is when "111"=>mode2<="110"led2<="010"led
22、_out<=led2;temp2<=15; when "110"=>mode2<="100"led2<="001"led_out<=led2;temp2<=0; when others=>led2<="000"temp2<=0;alarm<='1' end case; end if; end if; end if; end process; end; 3:仿真波形与分析 由图可知,在switch为1之后,数据输入。我仿真输入的是110
23、(漂洗+脱水),总时间为40,temp为15,led为010。在start为1是,时间开始减少,在减少到temp(15)时,模式改变,led变为001,可见在15s时有个暂停信号,实现了暂停。(五)时间处理模块 1:模块功能 此模块对控制模块传进来的时间进行处理,在对应的模式下,分别提取出剩余总时间的个位,十位数字和此模块剩余时间的个位十位数字,然后转化为二进制,方便数码管译码器的输出。 2:代码分析library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned;entity timechange isport( clk
24、:in std_logic; timecount:in integer range 0 to 70; -输入总时间 mode_out:in std_logic_vector( 2 downto 0); -选择的模式 t_1:out std_logic_vector( 1 downto 0); -分部时间十位 t_2:out std_logic_vector( 3 downto 0); -分部时间个位 a_1:out std_logic_vector( 2 downto 0); -总时间十位 a_2:out std_logic_vector( 3 downto 0) - 总时间个位 );end
25、timechange;architecture a of timechange is begin process(clk) variable t1:integer range 0 to 3; variable t2:integer range 0 to 9; variable a1:integer range 0 to 7; variable a2:integer range 0 to 9; Begin -根据模式不同,确定分部时间的值 if(mode_out="100" or mode_out="010" or mode_out="001&q
26、uot;) then if (timecount=0) then -无模式转换 t1:=0; t2:=0; elsif( timecount>0 and timecount<10) then t1:=0; t2:=timecount; elsif (timecount>=10 and timecount<20) then t1:=1; t2:=timecount-10; elsif (timecount>=20 and timecount<30) then t1:=2; t2:=timecount-20; else t1:=3; t2:=0; end if;
27、 elsif(mode_out="110" or mode_out="111") then -模式有转换的情况 if( timecount<10) then t1:=0; t2:=timecount; elsif (timecount>=10 and timecount<=15) then t1:=1; t2:=timecount-10; elsif(timecount>15 and timecount<25) then t1:=0; t2:=timecount-15; elsif(timecount>=25 and
28、timecount<35) then t1:=1; t2:=timecount-25; elsif(timecount>=35 and timecount<40) then t1:=2; t2:=timecount-35; elsif (timecount=40) then t1:=2; t2:=5; elsif( timecount>40 and timecount<50) then t1:=0; t2:=timecount-40; elsif( timecount>=50 and timecount<60) then t1:=1; t2:=time
29、count-50; elsif( timecount>=60 and timecount<70) then t1:=2; t2:=timecount-60; elsif( timecount=70) then t1:=3; t2:=0; end if; elsif(mode_out="000") then t1:=0; t2:=0; end if; if (timecount<10) then -根据总时间直接提取出个位十位 a1:=0; a2:=timecount; elsif (timecount>=10 and timecount<20)
30、 then a1:=1; a2:=timecount-10; elsif (timecount>=20 and timecount<30) then a1:=2; a2:=timecount-20; elsif (timecount>=30 and timecount<40) then a1:=3; a2:=timecount-30; elsif (timecount>=40 and timecount<50) then a1:=4; a2:=timecount-40; elsif (timecount>=50 and timecount<60)
31、 then a1:=5; a2:=timecount-50; elsif (timecount>=60 and timecount<70) then a1:=6; a2:=timecount-60; elsif (timecount=70) then a1:=7; a2:=0; end if; case t1 is -将个位十位都转化为2进制方便传输 when 0=>t_1<="00" when 1=>t_1<="01" when 2=>t_1<="10" when 3=>t_1&
32、lt;="11" end case; case t2 is when 0=>t_2<="0000" when 1=>t_2<="0001" when 2=>t_2<="0010" when 3=>t_2<="0011" when 4=>t_2<="0100" when 5=>t_2<="0101" when 6=>t_2<="0110" when 7=&
33、gt;t_2<="0111" when 8=>t_2<="1000" when 9=>t_2<="1001" end case; case a1 is when 0=>a_1<="000" when 1=>a_1<="001" when 2=>a_1<="010" when 3=>a_1<="011" when 4=>a_1<="100" when
34、 5=>a_1<="101" when 6=>a_1<="110" when 7=>a_1<="111" end case; case a2 is when 0=>a_2<="0000" when 1=>a_2<="0001" when 2=>a_2<="0010" when 3=>a_2<="0011" when 4=>a_2<="0100"
35、; when 5=>a_2<="0101" when 6=>a_2<="0110" when 7=>a_2<="0111" when 8=>a_2<="1000" when 9=>a_2<="1001" end case; end process; end; 3:仿真波形与分析 由图可知,为了方便仿真,我把时间设为从0开始加,模式为110(漂洗+脱水),可见总时间(a1,a2)和分部时间是不一样的,此程序实现了将两个时间的个位和十位都提
36、取出来的功能,为数码管显示打下了基础。(六)数码管显示模块 1:模块功能 此模块对输入进来的处理过的时间信号以及模式信号进行7段数码管的译码处理,形成显示代码传入数码管选通信号中。 2:代码分析library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned;entity showtime is port( mode_out:in std_logic_vector(2 downto 0); -模式 t1:in std_logic_vector(1 downto 0); -时间的个位十位 t2:in std_logic_ve
37、ctor(3 downto 0); a1:in std_logic_vector(2 downto 0); a2:in std_logic_vector(3 downto 0); dispmode:out std_logic_vector(6 downto 0); -转换后的数码管代码 dispt1:out std_logic_vector(6 downto 0); dispt2:out std_logic_vector(6 downto 0); dispta1:out std_logic_vector(6 downto 0); dispta2:out std_logic_vector(6 d
38、ownto 0) );end showtime;architecture a of showtime is begin p1:process(mode_out) begin case mode_out is -将模式信号转换为数码管代码 when "001"=>dispmode<="0110000" when "010"=>dispmode<="1101101" when "100"=>dispmode<="1111001" when &q
39、uot;110"=>dispmode<="0110011" when "111"=>dispmode<="1011011" when others =>dispmode<="1111110" end case; end process; p2:process(t1) begin case t1 is -将十位信号转换为数码管代码 when "00"=>dispt1<="1111110" when "01&qu
40、ot;=>dispt1<="0110000" when "10"=>dispt1<="1101101" when "11"=>dispt1<="1111001" when others=>dispt1<="0000000" end case; end process; p3:process(t2) begin case t2 is -将个位信号转换为数码管代码 when "0000"=>dispt2&l
41、t;="1111110" when "0001"=>dispt2<="0110000" when "0010"=>dispt2<="1101101" when "0011"=>dispt2<="1111001" when "0100"=>dispt2<="0110011" when "0101"=>dispt2<="101101
42、1" when "0110"=>dispt2<="1011111" when "0111"=>dispt2<="1110000" when "1000"=>dispt2<="1111111" when "1001"=>dispt2<="1111011" when others =>dispt2<="0000000" end case; end pr
43、ocess; p4:process(a1) begin case a1 is -将十位信号转换为数码管代码 when "000"=>dispta1<="1111110" when "001"=>dispta1<="0110000" when "010"=>dispta1<="1101101" when "011"=>dispta1<="1111001" when "100&quo
44、t;=>dispta1<="0110011" when "101"=>dispta1<="1011011" when "110"=>dispta1<="1011111" when "111"=>dispta1<="1110000" when others=>dispt1<="0000000" end case; end process; p5:process(a2) begin
45、 case a2 is -将个位信号转换为数码管代码 when "0000"=>dispta2<="1111110" when "0001"=>dispta2<="0110000" when "0010"=>dispta2<="1101101" when "0011"=>dispta2<="1111001" when "0100"=>dispta2<=&qu
46、ot;0110011" when "0101"=>dispta2<="1011011" when "0110"=>dispta2<="1011111" when "0111"=>dispta2<="1110000" when "1000"=>dispta2<="1111111" when "1001"=>dispta2<="1111011
47、" when others =>dispta2<="0000000" end case; end process; end; 3:仿真波形与分析 由图可知,此程序将输入的mode,时间的个位十位都转化为了对应的数码管显示代码。(七)数码管选通模式 1:模块功能 此模块使用600HZ的时钟扫描数码管,内部通过循环计数的方式使数码管能同时显示模式、总时间、模块时间。 2:代码分析library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned;entity opencontrol is
48、 port( clk:in std_logic; mode_out:in std_logic_vector(6 downto 0); t_1:in std_logic_vector(6 downto 0); t_2:in std_logic_vector(6 downto 0); a_1:in std_logic_vector(6 downto 0); a_2:in std_logic_vector(6 downto 0); disp:out std_logic_vector(6 downto 0); -数码管显示信号 control:out std_logic_vector(5 downto
49、 0) -管脚选通信号 );end opencontrol;architecture a of opencontrol is begin process(clk) variable s:integer range 0 to 4; begin if(clk'event and clk='1') then -循环计数,显示不同数字 if(s=4) then s:=0; else s:=s+1; end if; end if; case s is when 0=>control<="011111"disp<=mode_out; when 1=>control<="110111"disp<=a_1; when 2=>
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026铁塔智联技术有限公司招聘博士后研究人员5人备考题库带答案详解(完整版)
- 2026黑龙江省龙江化工有限公司招聘1人备考题库含答案详解(考试直接用)
- 2026浙江台州学院后勤发展有限公司招聘6人备考题库含答案详解(模拟题)
- 2026上海博物馆招聘3人备考题库及答案详解(夺冠)
- 【衢州】2025年浙江衢州市“智汇衢州”市县联动引进事业单位高层次紧缺人才395人笔试历年典型考题及考点剖析附带答案详解
- 2026浙江省自然资源集团有限公司校园招聘笔试历年参考题库附带答案详解
- 2026年中建三局第三建设工程有限责任公司校园招聘笔试历年参考题库附带答案详解
- 某水泥厂环保设备维护细则
- (2026年)世界老年人跌倒预防和管理指南及跌倒应急处理解读课件
- 施工道路维护与管理方案
- 2026年山西水利职业技术学院单招职业技能笔试模拟试题带答案解析
- 中国玫瑰痤疮诊疗指南(2025版)
- 供应室进修汇报课件
- 炼钢厂连铸设备培训
- 老年人慢性疼痛的针灸穴位优化方案
- 2025年大学民航概论试题及答案
- 浦东社工笔试试题及答案
- 音浪小球课件
- 养殖场申请审批报告标准模板
- 2025年健康服务与管理专升本健康管理试卷(含答案)
- (正式版)DB65∕T 4197-2019 《地理标志产品 和田大枣》
评论
0/150
提交评论