数字电路综合实验简易微波炉控制器.docx
- 文档编号:16091849
- 上传时间:2023-07-10
- 格式:DOCX
- 页数:36
- 大小:599.55KB
数字电路综合实验简易微波炉控制器.docx
《数字电路综合实验简易微波炉控制器.docx》由会员分享,可在线阅读,更多相关《数字电路综合实验简易微波炉控制器.docx(36页珍藏版)》请在冰点文库上搜索。
数字电路综合实验简易微波炉控制器
数字电路综合实验
姓名:
XXX
班级:
XXXX
学号:
XXX
班内序号:
XXX
1.设计任务要求
设计制作一个简易微波炉控制器。
大体要求:
1、微波炉的火力有大、中、小三档可选。
用一个按键实现火力的选择,用点阵显示火力档位,点阵的显示随着按键的按下次数而转变,没有选择时默许的火力为大。
2、微波加热时刻在0-59分59秒之间可选。
用4个按键别离设置加热时刻列位的长度,用数码管显示加热时刻。
3、设置一个开始键,按下此键后开始加热。
加热进程中,用数码管倒计时显示剩余时刻。
4、加热进程中,不能修改火力和加热时刻。
5、加热完成后蜂鸣器至少鸣响两声以提示利用者加热已结束,加热结束后回到等待状态。
6、设置复位键,任何时候按下复位键能够取消加热,回到等待状态,只有在等待状态下才能够修改火力和加热时刻。
提高要求:
1、用8个LED灯作为加热进度显示条,随着加热时刻的增加匀速增加点亮LED灯的个数,无论加热时刻是多长,最后都必需将8个LED灯全数点亮。
2、增加烧烤功能,用一个键选择微波或烧烤功能,用一个数码管指示当前处于微波仍是烧烤功能。
3、烧烤火力和加热时刻要求与微波功能相同。
4、自拟其它功能。
2.系统设计
设计思路
看到实验设计要求后,第一肯定了需要利用的硬件,如数码管、点阵、蜂鸣器、led灯和按键等。
然后再分出模块来,一步一步将功能分解成小模块,更易实现每一步的功能,容易仿真,不容易犯错,犯错也好查。
整体框图
图1硬件结构框图
图2模块划分
图3逻辑划分框图
图4ASM图
图5状态转移图
分块设计
这里只对其中几个模块进行说明,不说明的均是一些很简单的、显而易见的模块。
初始化模块
这是将整个电路的输入信号转化成适合程序处置和计算的信号或变量,再输出到其他模块中进行计算。
每那时钟检测到摸个信号变成高电平后,便对那个信号进行处置,比如输出信号自身加1,或置0。
减计数计时模块
由于在加热进程中,不允许设置时刻和火力,所以对reset键进行了特别的设置。
还有就是最核心的倒计时程序了。
我别离检测秒、十秒、分、十分4位的剩余时刻,进行减计数或借位等设置。
当检测到4位的时刻均为0时,倒计时结束。
并输出一个结束信号,控制蜂鸣器报警(这部份在蜂鸣器模块详细说明)。
点阵显示火力模块
我用三色点阵显示火力,点阵左侧是火苗,火苗大小表示火力大小,右边是一个火力条,火力条的高低表示火力大小。
我设置里两个行向量别离控制红色和绿色的led小灯亮暗,设置列向量进行列扫描,要亮起的一行置0,其余全数置1。
效果很漂亮。
数码管显示模块
这模块主如果和数据选择模块一路用。
按照书上数码管显示数字对应的高低电平设置好表格就好了,然后按照输入信号来选择需要显示的数字,按照已经写好的对应的高低电平,就可以够正常显示了。
蜂鸣器报警模块
那个模块实现的功能虽然很简单,可是我却碰到了很多困难。
第一碰到的困难是下载成功的同时蜂鸣器马上就报警,于是我在倒计时模块中加入了加热停止信号,在所有位都为0时,该信号置1。
可是还不成功,蜂鸣器在我按下start键后就响起来了,并非是在计时结束才响,我就又加了一个输入信号,末位必然不老是0才允许蜂鸣器报警。
接下来又碰到了新的问题,就是蜂鸣器不是响3下就停止报警,而是一个周期一个周期重复这3下报警,我又加了报警检测信号,计算报警的6秒时刻结束后,强制将蜂鸣器置0。
问题才解决。
3.仿真波形及波形分析
初始化文件first
图6初始化文件仿真波形
输入为时钟信号clk,时刻设置信号s3~s0,火力设置信号ffire。
输出波形为时刻计数信号o4~o1和火力大小信号firest。
减计数器倒计时模块jianjishu
图7减计数器倒计时模块仿真波形
输入为秒时钟信号clk,开始start,复位res,时刻输入信号in4~in1。
输出信号为时刻输出信号out4~out1,蜂鸣器响起信号light和两个倒计时结束信号c、d。
点阵显示火力模块fires
图8点阵显示火力模块仿真波形(三色小火)
输入为时钟信号clk,复位res,火力大小信号firee。
输出为行扫描信号r,红色灯列向量red,黄色led灯列向量yellow。
若是将图顺时针旋转90°,则能够看出red和yellow信号成一个小火苗状,火苗左侧为矮的小火力显示条。
图9点阵显示火力模块仿真波形(三色中火)
输入为时钟信号clk,复位res,火力大小信号firee。
输出为行扫描信号r,红色灯列向量red,黄色led灯列向量yellow。
若是将图顺时针旋转90°,则能够看出red和yellow信号成一个小中苗状,火苗左侧为矮的中火力显示条。
图10点阵显示火力模块件仿真波形(三色大火)
输入为时钟信号clk,复位res,火力大小信号firee。
输出为行扫描信号r,红色灯列向量red,黄色led灯列向量yellow。
若是将图顺时针旋转90°,则能够看出red和yellow信号成一个大火苗状,火苗左侧为矮的大力显示条。
(注意红色red和黄色yellow重叠起来看!
)
进度条显示模块进度条
图11进度条显示模块件仿真波形
输入为时钟信号clk,复位res,设置的加热时刻i4~i1,倒计时剩余时刻c4~c1。
输出为8个led灯向量ledd。
从图中能够看出,随着剩余时刻的减少,8个LED灯逐渐亮起。
蜂鸣器报警模块beep
图12蜂鸣器报警模块件仿真波形
输入信号为clk时钟信号,十秒位归零但秒位不归零信号kzero,倒计时结束信号zero。
当两个信号都被置1后,蜂鸣器报警3声,然后停止报警。
4.源程序
顶层文件top
libraryieee;
usetopis
port(rest,clk1,miao0,miao1,fen0,fen1,startt,fire,st:
instd_logic;
lighto:
outstd_logic;
row:
outstd_logic_vector(7downto0);
sel:
outstd_logic_vector(5downto0);
seg,redd,yel,led:
outstd_logic_vector(7downto0));
end;
architecturethreeoftopis
componentfenpinis
port(clk:
instd_logic;--分频
outclk,outclk2:
outstd_logic
);
endcomponent;
componentfirstis
port(clk,res,s0,s1,s2,s3,ffire:
instd_logic;--初始化数据
o1,o2,o3,o4:
outstd_logic_vector(3downto0);
firest:
outstd_logic_vector(1downto0));
endcomponent;
componentjianjishuis
port(clks,start,res:
instd_logic;
in1,in2,in3,in4:
instd_logic_vector(3downto0);--减计数
light,c,d:
outstd_logic;
out1,out2,out3,out4:
outstd_logic_vector(3downto0));
endcomponent;
componentchoiceis
port(clk:
std_logic;
f1,f2,f3,f4,f5:
instd_logic_vector(3downto0);
o1:
outstd_logic_vector(2downto0);--位选
o2:
outstd_logic_vector(3downto0));
endcomponent;
componentviewis
port(--screen:
instd_logic;
f1:
instd_logic_vector(2downto0);
f2:
instd_logic_vector(3downto0);--显示输出
segout:
outstd_logic_vector(7downto0);
selout:
outstd_logic_vector(5downto0));
endcomponent;
componentfiresis
port(res,clk:
instd_logic;
firee:
instd_logic_vector(1downto0);
red:
outstd_logic_vector(7downto0);
yellow:
outstd_logic_vector(7downto0);
r:
outstd_logic_vector(7downto0));
endcomponent;
componentshaokaois
port(clk,set:
instd_logic;
o2:
outstd_logic_vector(3downto0));
endcomponent;
componentbeepis
port(clks,zero,kzero:
instd_logic;
light:
outstd_logic);
endcomponent;
componentjindutiaois
port(clk,res:
instd_logic;
i1,i2,i3,i4,c1,c2,c3,c4:
instd_logic_vector(3downto0);
ledd:
outstd_logic_vector(7downto0));
endcomponent;
componentdoudongis
port(clk,res,min10,min1,sec10,sec1,huo,moshi:
instd_logic;
resn,min10n,min1n,sec10n,sec1n,huon,moshin:
outstd_logic);
endcomponent;
signalb,c,d,e,f,g,h,i,j,k:
std_logic_vector(3downto0);
signala,pp,zc,rest11,min1011,min111,sec1011,sec111,huo11,moshi11,clk22:
std_logic;
signalq:
std_logic_vector(2downto0);
signalfir:
std_logic_vector(1downto0);
signalp:
std_logic_vector(3downto0);
begin
u1:
fenpinportmap(clk=>clk1,outclk2=>clk22,outclk=>a);
u2:
firstportmap(clk=>clk1,res=>rest11,o1=>b,o2=>c,o3=>d,o4=>e,
s0=>sec111,s1=>sec1011,s2=>min111,s3=>min1011,ffire=>huo11,firest=>fir);
u3:
jianjishuportmap(clks=>a,start=>startt,res=>rest,in1=>b,in2=>c,in3=>d,in4=>e,
out1=>f,out2=>g,out3=>h,out4=>i,c=>zc,d=>pp);
u4:
choiceportmap(clk=>clk22,f1=>f,f2=>g,f3=>h,f4=>i,f5=>k,o1=>q,o2=>p);
u5:
viewportmap(f1=>q,f2=>p,segout=>seg,selout=>sel);
u6:
firesportmap(clk=>clk22,res=>rest11,firee=>fir,red=>redd,yellow=>yel,r=>row);
u7:
shaokaoportmap(clk=>clk1,set=>moshi11,o2=>k);
u8:
beepportmap(clks=>a,zero=>zc,light=>lighto,kzero=>pp);
u9:
jindutiaoportmap(clk=>clk1,res=>rest,i1=>b,i2=>c,i3=>d,i4=>e,c1=>f,c2=>g,c3=>h,c4=>i,ledd=>led);
u10:
doudongportmap(clk=>clk1,res=>rest,min10=>fen1,min1=>fen0,sec10=>miao1,sec1=>miao0,huo=>fire,moshi=>st,
resn=>rest11,min10n=>min1011,min1n=>min111,sec10n=>sec1011,sec1n=>sec111,huon=>huo11,moshin=>moshi11);
endthree;
分频器fenpin
libraryieee;
usefenpinis
port(clk:
instd_logic;
outclk,outclk2:
outstd_logic
);
end;
architecturefirstoffenpinis
signalQ1,Q2:
std_logic;
--signalQ2:
std_logic;
begin
one:
process(clk)
variablecount1:
integerrange0to;
begin
Q1<='0';
ifcount1>thenQ1<='1';count1:
=0;
elsifclk'eventandclk='1'thencount1:
=count1+1;--分出1秒信号
endif;
endprocess;
two:
process(clk)
variablecount2:
integerrange0to2999;
begin
Q2<='0';
ifcount2>2999thenQ2<='1';count2:
=0;
elsifclk'eventandclk='1'thencount2:
=count2+1;--分出100Hz信号
endif;
endprocess;
outclk<=Q1;
outclk2<=Q2;
end;
初始化模块first
libraryieee;
usefirstis
port(clk,res,s0,s1,s2,s3,ffire:
instd_logic;
o1,o2,o3,o4:
outstd_logic_vector(3downto0);
firest:
outstd_logic_vector(1downto0));
end;
architecturetwooffirstis
signalq1,q2,q3,q4:
std_logic_vector(3downto0);
begin
process(clk,res,q4)
variabless:
std_logic_vector(3downto0);
variablef:
std_logic_vector(1downto0);
begin
if(clk'eventandclk='1')then
ss(0):
=s0;ss
(1):
=s1;ss
(2):
=s2;ss(3):
=s3;
ifres='1'thenq1<="0000";q2<="0000";q3<="0000";q4<="0000";firest<="10";--复位键
else
if(ffire='1')then
if(f="10")thenf:
="00";
elsef:
=f+'1';
endif;
endif;
casessis
when"0001"=>ifq1<9thenq1<=q1+1;
elseq1<="0000";--秒位加数
endif;
when"0010"=>ifq2<5thenq2<=q2+1;
elseq2<="0000";--十秒位加数
endif;
when"0100"=>ifq3<9thenq3<=q3+1;
elseq3<="0000";--分位加数
endif;
when"1000"=>ifq4<5thenq4<=q4+1;
elseq4<="0000";--十分位加数
endif;
whenothers=>null;
endcase;
endif;
endif;
firest<=f;
endprocess;
o1<=q1;
o2<=q2;
o3<=q3;
o4<=q4;
end;
减计数器计时模块jianjishu
libraryieee;
usejianjishuis
port(clks,start,res:
instd_logic;
in1,in2,in3,in4:
instd_logic_vector(3downto0);
light,c,d:
outstd_logic;
out1,out2,out3,out4:
outstd_logic_vector(3downto0));
end;
architectureoneofjianjishuis
signalq1,q2,q3,q4:
std_logic_vector(3downto0);
begin
process(start,clks,res,q4)
variablea:
std_logic_vector(1downto0);
begin
ifres='1'then
q1<=in1;q2<=in2;q3<=in3;q4<=in4;
--对信号都清零设置
elsifq4=(in4-15)orstart='0'thenlight<='0';
--当q4=15或start=0时不进行减计数,同时LED不亮
elsifstart='1'then
--当start=1时LED点亮同时开始倒计时
if(clks'eventandclks='1')then
if(in1-q1)=0thenq1<=(in1-9);q2<=q2+1;
elseq1<=q1+1;
endif;
--q1开始为0,当q1=in1时,对q1赋值为(in1-9),为负数,
--同时对q2进行加1,那么(in2-q2)就可以够视线减1,若不是那么q1<=q1+1,能够实现
--(in1-q1)从9开始的倒计数
if(in2-q2)=0and(in1-q1)=0then
q3<=q3+1;q2<=(in2-5);q1<=(in1-9);
endif;
--当输出out1=0和out2=0时进位减1,同时out1=9,out2=5;
if(in3-q3)=0and(in2-q2)=0and(in1-q1)=0then
q4<=q4+1;q3<=(in3-9);q2<=(in2-5);q1<=(in1-9);d<='1';
endif;
if(in4-q4)=0and(in3-q3)=0and(in2-q2)=0and(in1-q1)=0
thenq4<=in4;q3<=in3;q2<=in2;q1<=in1;c<='1';
endif;
--当所有计数完毕
endif;
endif;
endprocess;
out1<=(in1-q1);
out2<=(in2-q2);
out3<=(in3-q3);
out4<=(in4-q4);
end;
数据选择器choice
libraryieee;
usechoiceis
port(clk:
instd_logic;
f1,f2,f3,f4,f5:
instd_logic_vector(3downto0);
o1:
outstd_logic_vector(2downto0);
o2:
outstd_logic_vector(3downto0));
end;
architectureoneofchoiceis
signalq:
std_logic_vector(2downto0);
begin
process(clk,q)
begin
ifclk'eventandclk='1'thenq<=q+1;
endif;
caseqis
when"000"=>o2<=f1;
when"001"=>o2<=f2;
when"010"=>o2<=f3;--选择输出数据
when"011"=>o2<=f4;
when"100"=>o2<=f5;
whenothers=>null;
endcase;
endprocess;
o1<=q;--位选信号
end;
数码管显示模块view
libraryieee;
useviewis
port(--screen:
instd_logic;
f1:
instd_logic_vector(2downto0);
f2:
instd_logic_vector(3downto0);
segout:
outstd_logic_vector(7downto0);
selout:
outstd_logic_vector(5downto0));
end;
architectureoneofviewis
signalseg:
std_logic_vector(6downto0);
signalsel:
std_logic_vector(5dow
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数字电路 综合 实验 简易 微波炉 控制器