洗衣机控制器数字逻辑课程设计报告_第1页
洗衣机控制器数字逻辑课程设计报告_第2页
洗衣机控制器数字逻辑课程设计报告_第3页
洗衣机控制器数字逻辑课程设计报告_第4页
洗衣机控制器数字逻辑课程设计报告_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、石家庄经济学院华信学院数字逻辑课程设计报告题 目 洗衣机控制器 姓 名 学 号 班 号 指导老师 成 绩 2014年6月目 录1. 课程设计目的2. 开发工具选择3. 设计方案 4 模块描述5. VHDL实现6. 调试仿真7. 课程设计回顾总结 参 考 文 献 附录 1课程设计目的设计一个洗衣机控制器,控制洗衣机的电机按照下图要求运转。用两位数码管预置洗涤时间(分钟数),洗涤过程在送入预置时间后开始运转,洗涤中按倒计时方式对洗涤过程作计时显示,用LED表示电动机的正、反转,如果定时时间到,则停机并发出音响信号。 2开发工具选择(1) 硬件描述语言洗衣机控制器的设计采用了功能强大的VHDL语言,

2、它具有很强的行为能力描述,设计方法灵活,可以支持库和模块设计方法。 (2) QuartusII软件开发工具 本设计采用的软件开发工具是美国的Altera公司的QuartusII,它支持多种设计输入方法,包括原理图输入、文本输入。 (3) EDA实验开发系统 本设计采用的EDA实验开发系统,主要用于提供可编程逻辑器件的下载电路及EDA实验开发的外围资源,供硬件验证用。3设计方案总体思路:洗衣机启动后,将依次经过正转15s、暂停5秒、反转15秒、暂停5秒四个步骤(状态)。在实例中,假设定时时间为40秒,故经过这四个状态后时间到,停止。具体实现:此设计问题可分为洗涤预置时间编码寄存电路模块、十进制减

3、法计数器模块、时序电路模块、译码驱动模块四大部分。 设置预置信号LD,LD有效后,可以对洗涤时间计数器进行预置数,用数据开关K1-K10分别代表数字1,2,9,0,用编码器对数据开关K1-K10的电平信号进行编码,编码器真值表如下表所示,编码后的数据寄存。 设置洗涤开始信号start,start有效,则洗涤时间计数器进行倒计数,并用数码管显示,同时启动时序电路工作。 时序电路中含有15s定时信号,5s定时信号,设为A、B,A、B为“0”表示定时时间未到,为“1”表示定时时间到。 设置电动机正转信号run、反转信号rev、暂停信号Pause,由时序电路的输出Q2Q1经译码驱动模块,可使显示信号正

4、确反映电路的工作状态。直到洗涤计时时间到,时序电路异步复位。 流程图如下: 4模块描述(1) 模块一:预设时间和编码电路(yuzhitime)接受用户通过按钮预置的时间信息,编码成八位之后转给减法计数器。(2) 模块二:减法计数器电路(counter) 接收编码之后的预置时间信息,向电机运转控制电路传递运行信号,并将预置时间信息和剩余时间信息发给数码管显示电路进行实时显示。(3) 模块三:数码管显示电路(showtime)接收减法计数器电路传来的时间信息,进行实时译码显示(4) 模块四:电机运转时序控制电路(shixu)接收运行起止信号,安排电机运行状态并编码输出。(5) 模块五:译码器(mo

5、ve)接收电机运行状态信号,译码后实时控制电机的正传、反转和暂停。5 VHDL实现模块一:预设时间和编码电路(yuzhitime)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity yuzhitime isport(load,clk:in std_logic; time_input:in std_logic_vector(3 downto 0); time_set:out std_logic_vector(7 downto 0);end yuzhitime;architecture yu

6、zhitime of yuzhitime is signal p1:std_logic_vector(7 downto 0);begin process(time_input)is begin case time_input is when "0000"=>p1<="00000000" when "0001"=>p1<="00000001" when "0010"=>p1<="00000010" when "0011"=

7、>p1<="00000011" when "0100"=>p1<="00000100" when "0101"=>p1<="00000101" when "0110"=>p1<="00000110" when "0111"=>p1<="00000111" when "1000"=>p1<="00001000"

8、; when "1001"=>p1<="00001001" when "1010"=>p1<="00001010" when others=>p1<="00000000" end case; end process; time_set<=p1;end yuzhitime;其中,time_input为通过开发板上按钮输入的信号,load为输入确认信号。本模块将输入的四位时间信息编码输出到减法计数器电路。模块二:减法计数器电路(counter)library

9、 ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity counter is port ( clk,start:in std_logic; time_set:in std_logic_vector(7 downto 0); time_remain:buffer std_logic_vector(7 downto 0); time_over:buffer std_logic );end counter;architecture counter of counter is begin process(clk)

10、 variable time_second:integer range 0 to 59:=59; begin if(clk'event and clk='1') then if(start='0') then if(time_remain(7 downto 0)=0) then time_remain<=time_set; else time_remain(7 downto 4)<=time_remain(3 downto 0); time_remain(3 downto 0)<=time_set(3 downto 0); end if

11、; time_second:=59; time_over<='1' else if(time_over='1') then if(time_second=0 and time_remain(7 downto 0)=0) then time_over<='0' else if(time_second=0) then if (time_remain(3 downto 0)=0) then time_remain(7 downto 4)<=time_remain(7 downto 4)-1; time_remain(3 downto

12、0)<="1001" time_second:=59; else time_remain(7 downto 4)<=time_remain(7 downto 4); time_remain(3 downto 0)<=time_remain(3 downto 0)-1; time_second:=59; end if; else time_second:=time_second-1; end if; end if; end if; end if; end if; end process;end counter;本模块中clk为系统时序脉冲信号,start为系

13、统开始运行的信号,time_set为从预置时间模块接收到的时间编码信号,time_remain为输出到数码管显示电路的时间信号,time_is_up为系统运行结束信号。在系统运行的开始时期,用户第一次输入的预置时间会被赋给个位,第二次输入的时间会被赋给十位,可以进行多次输入,以前的会被覆盖。模块三:数码管显示电路(showtime)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity showtime is port ( time_remain:in std_logic_vector(7

14、downto 0); clk:in std_logic; minute,second:out std_logic; a,b,c,d,e,f,g: out std_logic );end showtime;architecture showtime of showtime is signal temp:std_logic_vector(6 downto 0); signal bcd:std_logic_vector(3 downto 0); signal choose:std_logic; begin process(clk) begin if(clk'event and clk=

15、9;1') then choose<=not choose; if(choose='1') then minute<='0'second<='1' bcd<=time_remain(7 downto 4); else minute<='1'second<='0' bcd<=time_remain(3 downto 0); end if; end if; end process; process(bcd) begin case bcd is when "00

16、00"=>temp<="1111110" ; when "0001"=>temp<="0110000" ; when "0010"=>temp<="1101101" ; when "0011"=>temp<="1111001" ; when "0100"=>temp<="0110011" ; when "0101"=>te

17、mp<="1011011" ; when "0110"=>temp<="1011111" ; when "0111"=>temp<="1110000" ; when "1000"=>temp<="1111111" ; when "1001"=>temp<="1111011" ; when others=>temp<="1111011"

18、; ; end case; a<=temp(6);b<=temp(5);c<=temp(4);d<=temp(3);e<=temp(2);f<=temp(1);g<=temp(0); end process;end showtime;接收减法计数器电路传来的时间信息,进行实时译码显示,由于我们的实际是可以进行两位的时间显示的,所以开始的时候是用的两个数码管,后来见到硬件芯片上是只有一个,又修改成了一个,但为了进行两位的显示,我们就设计了两个小灯,每个小灯分别代表十位和个位,当某个小灯被点亮时代表当前显示的是对应位的数值,每个一秒转换一次,这样就可以实现

19、两位的显示了。模块四:电机运转时序控制电路(shixu)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity shixu is port ( clk,start,time_over:in std_logic; q1,q2:out std_logic );end shixu;architecture shixu of shixu is begin process(clk) variable state:std_logic; variable wash_time:integer :=0; va

20、riable wait_time:integer :=0; begin if(clk'event and clk='1') then if(start='0') then wash_time:=0; wait_time:=0; state:='0' q1<='0'q2<='0' else if(time_over='1') then if(wash_time=20) then if(wait_time=9) then wash_time:=0; state:=not state;

21、 else wait_time:=wait_time+1; end if; else wash_time:=wash_time+1; wait_time:=0; end if; end if; if(wash_time=20) then q1<='0'q2<='0' else if(state='0') then q1<='1'q2<='0' else q1<='0'q2<='1' end if; end if; end if; end if; e

22、nd process;end shixu;通过时钟的输入进行计算当前系统应该处的状态,并进行编码输出电机的运转状态。由于在显示以及输入的时候只有分钟,故需要内设一个秒的计时变量。模块五:译码器(move)library ieee;use ieee.std_logic_1164.all;entity move is port( q1,q2: in std_logic; REV,RUN,PAUSE: buffer std_logic );end move;architecture move of move is begin REV<=q2;RUN<=q1;PAUSE<=not(q

23、1 OR q2);end move;分析输入的电机转动编码信号,即为思路中的Q1何Q2,安排电机运行状态并进行输出。主程序(wash)用来将各个模块进行组合,从而实现一个可以运行的系统。程序代码如下所示:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use work.all;entity wash is port ( load:in std_logic; time_input:in std_logic_vector(3 downto 0); clk:in std_logic; start:in

24、std_logic; time_set:buffer std_logic_vector(7 downto 0); time_over:buffer std_logic; REV,RUN,PAUSE: buffer std_logic; a,b,c,d,e,f,g: buffer std_logic; minute,second:buffer std_logic );end wash;architecture wash of wash is component yuzhitime port ( load:in std_logic; time_input:in std_logic_vector(3

25、 downto 0); time_set:out std_logic_vector(7 downto 0) ); end component; component counter port ( clk,start:in std_logic; time_set:in std_logic_vector(7 downto 0); time_remain:buffer std_logic_vector(7 downto 0); time_over:buffer std_logic ); end component; component showtime port ( time_remain:in st

26、d_logic_vector(7 downto 0); clk:in std_logic; minute,second:out std_logic; a,b,c,d,e,f,g: out std_logic ); end component; component shixu port ( clk,start,time_over:in std_logic; q1,q2:out std_logic ); end component; component move port ( q1,q2: in std_logic; REV,RUN,PAUSE: buffer std_logic ); end co

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论