课 程 设 计
课 程 EDA技术课程设计
题 目 洗衣机控制器设计
院 系 电子科学学院
专业班级 电子信息工程
学生姓名
学生学号
指导教师
2010年 3 月8日
大庆石油学院课程设计任务书
课程 EDA技术课程设计
题目 洗衣机控制器设计
专业 电子信息工程 姓名 杜鹏飞 学号 ************
主要内容、基本要求、主要参考资料等
主要内容:
设计一个洗衣机控制器,要求洗衣机有正转、反转、暂停三种状态。设定洗衣机的工作时间,要洗衣机在工作时间内完成:定时启动正转20秒暂停10秒反转20秒暂停10秒定时未到回到“正转20秒暂停10秒……”,定时到则停止,同时发出提示音。
基本要求:
1、设计一个电子定时器,控制洗衣机作如下运转:定时启动正转20秒暂停10秒反转20秒暂停10秒定时未到回到“正转20秒暂停10秒……”,定时到则停止;
2、若定时到,则停机发出音响信号;
3、用两个数码管显示洗涤的预置时间(分钟数),按倒计时方式对洗涤过程作计时显示,直到时间到停机;洗涤过程由“开始”信号开始;
4、三只LED灯表示“正转”、“反转”、“暂停”三个状态。
主要参考资料:
[1] 潘松著.EDA技术实用教程(第二版). 北京:科学出版社,2005.
[2] 康华光主编.电子技术基础 模拟部分. 北京:高教出版社,2006.
[3] 阎石主编.数字电子技术基础. 北京:高教出版社,2003.
完成期限 2010.3.12
指导教师
专业负责人
2010年 3月12 日
一、总体设计思想
1、基本原理
洗衣机控制器的设计主要是定时器的设计。由一片FPGA和外围电路构成了电器控制部分。FPGA接收键盘的控制命令,控制洗衣机的进水、排水、水位和洗衣机的工作状态、并控制显示工作状态以及设定直流电机速度、正反转控制、制动控制、起停控制和运动状态控制。对芯片的编程采用模块化的VHDL (硬件描述语言)进行设计,设计分为三层实现,顶层实现整个芯片的功能。顶层和中间层多数是由VHDL的元件例化语句实现。中间层由无刷直流电机控制、运行模式选择、洗涤模式选择、定时器、显示控制、键盘扫描、水位控制以及对直流电机控制板进行速度设定、正反转控制、启停控制等模块组成,它们分别调用底层模块。
2、设计框图
定时时间未到
二、设计步骤和调试过程
1、总体设计电路
洗衣机控制器电路主要有五大部分组成,包括:减法计数器、时序控制电路、预置时间和编码电路、数码管显示、译码器组成。
具体电路如下图所示:
2、模块设计和相应模块程序
⑴数码管显示
实现数码管显示
Library iee;
Use ieee.std_logic_11.all;
Entity encode is
Port(
Bcd : in std_logic_vector(3 downto o);
A,b,c,d,e,f,g: out std_logic
);
End encode;
Architecture rtl of encode is
Signal temp:std_logic_vector(6 downto 0);
Begin
Table
Bcd => temp;
"0000"=> "1111110";
"0001"=> "0110000"
"0010"=> "1101101"
"0011"=> "1111001"
"0100"=> "0110011"
"0101"=> "1011011"
"0110"=> "1011111"
"0111"=> "1110000"
"1000"=> "1111111"
"1001"=> "1111011"
End table;
a<=temp(6);b<=temp(5);c<=temp(4);d<=temp(3);e<=temp(2);f<=temp(1);
g<=temp(0);
end rtl
⑵时序电路
Library ieee;
Use ieee.std_logic_11.all;
Use ieee.std_logic_unsigned.all
Entity shixu is
Port(cp,en,rd:in std_logic;
Q1,q2:out std_logic);
End shixu;
Architecture rtl of shixu is
Begin
Process(cp)
Variable wash_time:integer range 0 to 19;
Variable wash_time:integer range 0 to 9;
Variable state:std_logic;
Variable wash_time:integer :=21;
Variable wash_time:integer :=9;
Begin
If(en=’0’)wash_time:=’19’;wait_time:=’9’;state:=’0’;
End if;if(en=’0’)then wash_time:=21;Q1<=’0’;Q2<=’0’;
Else if (cp’event and cp=’1’)
Then if (rd=’1’)then if (wash_time>0)
Then wash_time:=20;state:=not state;
End if; end if; end if;
If(wash_time=0)then Q1<=’0’;Q2<=’0’;else if (state=’0’)
Then Q1<=’1’;Q2<=’0’; else Q1<=’0’;Q2<=’1’;
End if; end if;
Else Q1<=’0’;Q2,=’0’;
End if;
End if;
End if;
End process;
End rtl;
⑶预置时间和编码电路
Library ieee;
Use ieee.std_logic_11.all;
Use ieee.std_logic_unsigned;all;
Entity counter is
Port(clk,start:in std_logic;
k:in STD_LOGIC_VECTOR(7 downto 0);
time_remain:BUFFER STD_LOGIC_VECTOR(7 DOWNTO 0);
time_is_up:out std_logic);
end counter;
architecture rtl of counter is
begin
process(clk)
variable time_second:integer:=60;
variable time_second:integer:=0;
begin if (clk’event and clk=’1’)
then if(time_second>0 and start=’1’)
then time_second:=time_second-1;
else time_second:=59; end if;
if(start=’0’)
then time_remain<=k;time_second:=60;
time_second:=0;else
if(time_second=0)
then if(time_remain(3 downto 0)>0)
then time_remain(3 downto 0)<=time_remain(3 downto 0)-start;
time_remain(3 downto 0)<=time_remain(3 downto 0)-1;time_second:=59;
else if (time_remain(7 downto 4) >0)
then time_remain(7 downto 4) <=time_remain(7 downto 4)-start;
time_remain(7 downto 4)<=time_remain(7 downto 4)-1;
time_remain(3 downto 0)<="1001";time_second:=59;end if; end if;
else if (time_second=0 and time_second=1)
if(time_remain=0)then time_is_up<=’0’;else time_is_up<=’1’;
time_second:=time_second-1;end if;end if;end if;
end if;end process; end rtl;
⑷译码器
library ieee;
use ieee.std_logic_11.all;
entity decoder is
port( Q1,Q2: in std_logic;
REV,RUN,PAUSE: out std_logic );end decoder;
architecture rtl of decoder is
signal choose:std_logic_vector(1 downto 0);
begin
choose(1)<=q1;choose(0)<=q2;
process(choose)
begin
case choose is
when "00"=>REV<='0';RUN<='0';PAUSE<='1';
when "10"=>REV<='0';RUN<='1';PAUSE<='0';
when "01"=>REV<='1';RUN<='0';PAUSE<='0';
when others=>REV<='0';RUN<='0';PAUSE<='0';
end case;
end process;
REV<=Q2;RUN<=Q1;PAUSE<=not(Q1 OR Q2);
end rtl;
3、仿真及仿真结果分析
仿真信号图如下:
仿真图
洗衣机接通电源,按load设置洗涤时间按start、rd置为高电平洗衣机开始工作,当时钟第一个上升沿到达时run(正转功能)为高电平维持20s以后变为低电平而pause(暂停功能)随着时钟上升沿的到来变为高电平维持10s变为低电平,然后rev(反转功能)开始随着时钟上升沿的到来变为高电平工作维持20s后变为低电平,再停止pause置高,接下来电路一直重复上述工作,知道定时器计数结束。
4、实验调试结果
电路设计完成以后,按照预定设计,输入相应数据,三只LED灯按照设定时间规律间断性亮起,数码管也显示输入时间并按减数计时产生相应的数字显示,直到到达预定时间停止工作显示零,实验设计达到预期效果。
三、结论及心得体会
家电控制电路设计在一片FPGA芯片内,具有体积小、可靠性高、设计周期短,功能灵活的特点。这尤其适用于小批量多品种新产品的开发,以满足人们追求新异、个性化的高品质生活的要求。
通过这次课程设计我对FPGA的编程更加熟悉,对定时器和计数器的设计,让我更加明白时序组合门电路设计思路和方法。而且自已思考与设计,使我初步掌握了VHDL的设计方法与一些技巧,本人从中受益匪浅。通过这个实验设计,我更加熟练地掌握了一些常见的数字芯片的设计方法,在设计中也参了和查阅了很多资料,从中学到不少课本上没有的东西。
参考资料
[1] 潘松著.EDA技术实用教程(第二版). 北京:科学出版社,2005.
[2] 康华光主编.电子技术基础 模拟部分. 北京:高教出版社,2006.
[3] 阎石主编.数字电子技术基础. 北京:高教出版社,2003.
大庆石油学院课程设计成绩评价表
课程名称 | EDA技术课程设计 | ||||||||
题目名称 | 洗衣机控制器 | ||||||||
学生姓名 | 杜鹏飞 | 学号 | 060901140328 | 指导教师姓名 | 职称 | ||||
序号 | 评价项目 | 指 标 | 满分 | 评分 | |||||
1 | 工作量、工作态度和出勤率 | 按期的完成了规定的任务,难易程度和工作量符合教学要求,工作努力,遵守纪律,出勤率高,工作作风严谨,善于与他人合作。 | 20 | ||||||
2 | 课程设计质量 | 课程设计选题合理,计算过程简练准确,分析问题思路清晰,结构严谨,文理通顺,撰写规范,图表完备正确。 | 45 | ||||||
3 | 创新 | 工作中有创新意识,对前人工作有一些改进或有一定应用价值。 | 5 | ||||||
4 | 答辩 | 能正确回答指导教师所提出的问题。 | 30 | ||||||
总分 | |||||||||
评语: |