数电 电子 课程设计 洗衣机实验报告 兼程序Word格式.docx
《数电 电子 课程设计 洗衣机实验报告 兼程序Word格式.docx》由会员分享,可在线阅读,更多相关《数电 电子 课程设计 洗衣机实验报告 兼程序Word格式.docx(40页珍藏版)》请在冰豆网上搜索。
![数电 电子 课程设计 洗衣机实验报告 兼程序Word格式.docx](https://file1.bdocx.com/fileroot1/2023-2/3/ec8eb1d0-3a79-48e6-8cd2-2981978e169f/ec8eb1d0-3a79-48e6-8cd2-2981978e169f1.gif)
entityxiyijiis
port(
clk0,clk1,rst,alarm:
instd_logic;
-----clk0:
控制开关脉冲.clk1:
记时开关脉冲.Rst:
复位端.arlarm:
报警输入端.-------
water_inh,water_inl,im_th,im_tl,wash_th:
instd_logic_vector(3downto0);
wash_tl,water_outh,water_outl,dry_th,dry_tl:
-----进水,浸泡,洗涤,出水,甩干指数端高位和地位输入端-----------
water_in,water_out,immersion,dry,z1,z2,voice,poweroff:
outstd_logic;
-----进水,出水,浸泡,甩干,洗涤,响铃,断电输出端-------
display_mh,display_ml,display_sh,display_sl:
outstd_logic_vector(3downto0)
-------------------输出时间显示高位低位输出端-------------
);
endentityxiyiji;
architecturebehaveofxiyijiis
signaljs,js_ten:
std_logic;
signalim,im_ten:
signalwa,wa_ten:
signalwa1,wa2,pwf:
signalcs,cs_ten:
signaldr,dr_ten:
signalxl,xl_ten:
signaljs_dh,js_dl,js_h,js_l:
std_logic_vector(3downto0);
signalim_dh,im_dl,im_h,im_l:
signalwa_dh,wa_dl,wa_h,wa_l:
signalcs_dh,cs_dl,cs_h,cs_l:
signaldr_dh,dr_dl,dr_h,dr_l:
signalxl_dh,xl_dl,xl_h,xl_l:
signaldis_mh,dis_ml:
std_logic_vector(3downto0);
signaldis_sh,dis_sl:
begin
-----------------------控制:
控制器件实现洗衣机的功能:
进水->
浸泡->
洗涤->
出水->
甩干->
响铃->
断电---------------
process(clk0,rst,alarm)
variablen:
integer;
begin
ifalarm='
1'
then
pwf<
='
;
----------判断是否有报警信号,有报警信号则pwf有效------
else
ifrst='
then--------判断置位信号-------
n:
=0;
im_ten<
0'
js_ten<
wa_ten<
cs_ten<
dr_ten<
xl_ten<
----初始状态¬
-----
elsifclk0='
andclk0'
eventthen
ifn=0then
ifwater_inh="
0000"
andwater_inl="
=1;
-----water_in不全为零则直接进入下一状态,不为零则继续判断-------
-----water_in不全为零则有js_ten为有效信号,使进水计时开始--------
ifjs='
then-------进水计时时会使js为有效-----
-----进入进水状态¬
endif;
elsifjs='
andn=1then------进水结束后js重新变为零,该判断有效------
ifim_th="
andim_tl="
=2;
ifim='
elsifim='
andn=2then
ifwash_th="
andwash_tl="
=3;
ifwa='
elsifwa='
andn=3then
ifwater_outh="
andwater_outl="
=4;
ifcs='
elsifcs='
andn=4then
ifdry_th="
anddry_tl="
=5;
ifdr='
elsifdr='
andn=5then
ifxl_dh="
andxl_dl="
=6;
ifxl='
elsifxl='
andn=6then
endprocess;
-----------------------------记时-----------------------------
------------------进水记时--------------------------
process(clk1,js_ten)
ifjs_ten='
then---------当js_ten为1时,该判断无效,进入下一个判断-------
js_dh<
=water_inh;
js_dl<
=water_inl;
js_h<
="
js_l<
js<
elsifclk1='
andclk1'
ifjs_dh="
andjs_dl="
andjs_h="
andjs_l="
---------从对电路图中可看出js_dl被设为0101,该判断无效-----
if(js_dl="
)then
1001"
0101"
=js_dh-1;
elsif(js_h="
)then------本条判断有效-------
=js_dl-1;
-----计数时js_dl减小,当计数结束,js_dl,js_h,js_l变为零,第一条判断有效,js变为零,满足下一个状态的条件-------
elsifjs_l="
then
=js_h-1;
elsifjs_l>
"
=js_l-1;
endif;
endprocess;
-------------浸泡记时----------------------
process(clk1,im_ten)
ifim_ten='
im_dh<
=im_th;
im_dl<
=im_tl;
im_h<
im_l<
im<
ifim_dh="
andim_dl="
andim_h="
andim_l="
if(im_dl="
andim_h="
andim_l="
=im_dh-1;
elsif(im_h="
=im_dl-1;
elsifim_l="
=im_h-1;
elsifim_l>
=im_l-1;
-----------------洗涤记时----------------------
process(clk1,wa_ten)
variablem:
ifwa_ten='
wa_dh<
=wash_th;
wa_dl<
=wash_tl;
wa_h<
wa_l<
wa<
wa1<
wa2<
m:
ifwa_dh="
andwa_dl="
andwa_l="
andwa_h="
wa2<
ifm=1then
elsifm=11then
elsifm=14then
elsifm=24then
elsifm=27then
----m为循环的递增变量,m的不同状态可以控制洗衣机的正反转------
=m+1;
if(wa_dl="
andwa_h="
andwa_l="
=wa_dh-1;
------wa_dh的初值根据开关来设置-----
elsif(wa_h="
=wa_dl-1;
elsifwa_l="
=wa_h-1;
elsifwa_l>
=wa_l-1;
--------------出水记时---------------------------
process(clk1,cs_ten)
ifcs_ten='
cs_dh<
=water_outh;
cs_dl<
=water_outl;
cs_h<
cs_l<
cs<
ifcs_dh="
andcs_dl="
andcs_h="
andcs_l="
if(cs_dl="
andcs_h="
andcs_l="
elsif(cs_h="
=cs_dl-1;
elsifcs_l="
=cs_h-1;
elsifcs_l>
=cs_l-1;
--------------甩干记时-----------------------
process(clk1,dr_ten)
ifdr_ten='
dr_dh<
=dry_th;
dr_dl<
=dry_tl;
dr_h<
dr_l<
dr<
ifdr_dh="
anddr_dl="
anddr_h="
anddr_l="
if(dr_dl="
anddr_h="
anddr_l="
=dr_dh-1;
elsif(dr_h="
=dr_dl-1;
elsifdr_l="
=dr_h-1;
elsifdr_l>
=dr_l-1;
------------------响铃记时----------------------
process(clk1,xl_ten)
ifxl_ten='
xl_dh<
="
xl_dl<
0010"
xl_h<
xl_l<
xl<
andxl_h="
andxl_l="
if(xl_dl="
andxl_h="
andxl_l="
=xl_dh-1;
elsif(xl_h="
=xl_dl-1;
elsifxl_l="
=xl_h-1;
elsifxl_l>
"
=xl_l-1;
----------------------------显示时间--------------------------
process(clk1,js_ten,im_ten,wa_ten,dr_ten,xl_ten)
ifjs_ten='
andim_ten='
andwa_ten='
andcs_ten='
anddr_ten='
andxl_ten='
then--------在进水时-----
ifclk1='
dis_mh<
=js_dh;
dis_ml<
=js_dl;
-----显示分钟----
dis_sh<
=js_h;
dis_sl<
=js_l;
------显示秒钟------
elsifim_ten='
then---------在浸泡时,此时js_ten任然为1,只是不作为判别依据------
=im_dh;
=im_dl;
=im_h;
=im_l;
elsifwa_ten='
=wa_dh;
=wa_dl;
=wa_h;
=wa_l;
elsifcs_ten='
=cs_dh;
=cs_dl;
=c