1775.自动售货机控制系统设计报告.doc
《1775.自动售货机控制系统设计报告.doc》由会员分享,可在线阅读,更多相关《1775.自动售货机控制系统设计报告.doc(13页珍藏版)》请在三一办公上搜索。
1、自动售货机控制系统设计报告一、课题介绍 自动售货机在当今社会已十分普遍,在各大商场和街头均能找到它的身影,它为人们购买一些常见小商品提供了极大的方便。本数字系统模仿一个小型自动售货机的功能,旨在初步学会数字系统设计的一般方法,提高使用Quartus 软件和运用VHDL语言编写程序的能力。该系统设定自动售货机出售可乐(2元)和汉堡包(4元)2种商品,可以选择所要购买的商品数量(1个或2个),按“确认”后进行投币。本机接受1元和5元的纸币,按投币键若干次。若投入的钱款总额达到应付金额,商品给出并找零;若投入的钱款总额未达到应付金额,商品不给出,此时按“取消”可退出已投入的钱款。该系统的规模较小。二
2、、具体实施方案用8个开关作为控制输入(由0变为1再变为0算一次输入),7个LED灯作为指示输出,4个数码管分别显示找零金额和退币金额。利用Quartus 软件编写VHDL程序,并下载到Cyclone EP1C6Q240C8芯片中,以实现其功能。三、面板图:退币欢迎使用自动售货机!可乐(2元)汉堡包(4元)1个2个找零确认商品给出取消1元5元复位确认取消图例:开关 标签 LED指示灯 四、系统结构图:开关模块消抖模块LED指示灯数码管控制模块译码模块开始选择商品YESNO选择数量YESNO确认投币钱款已够YESNOYESNO“商品给出”指示灯亮“确认”指示灯亮数量指示灯亮商品指示灯亮取消购买YE
3、S退币数码管显示退款数NO找零数码管显示找零数复位五、状态流程图:六、程序清单1、vendor.vhd-库定义library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;-实体定义entity vendor isport(cola: in std_logic; -选择可乐开关hamburger: in std_logic; -选择汉堡开关sum1: in std_logic; -选择购买1个开关sum2: in std_logic; -选择购买2个开关
4、note1: in std_logic; -1元纸币投掷开关note5: in std_logic; -5元纸币投掷开关rst: in std_logic; -复位开关ok: in std_logic; -确认开关cancel: in std_logic; -取消开关clk : in std_logic; -时钟信号led_cola: out std_logic; -选择可乐指示灯led_hamburger: out std_logic; -选择汉堡指示灯led_sum1: out std_logic; -选择购买1个指示灯led_sum2: out std_logic; -选择购买2个指示灯
5、led_ok: out std_logic; -确认指示灯led_cancel: out std_logic; -取消指示灯led_out: buffer std_logic; -商品给出指示灯change_money: buffer integer range 0 to 14; -商品给出后的找零return_money: buffer integer range 0 to 10 -商品未给出的退币);end vendor;-结构体定义architecture vendor_arc of vendor issignal hold_ok: std_logic; -保持ok信号signal ho
6、ld_cancel: std_logic;-保持cancel信号signal money_ok: std_logic; -钱款已够信号signal cola_choice: std_logic; -保持选择商品信号signal hamburger_choice: std_logic; signal sum1_choice: std_logic; -保持选择数目信号signal sum2_choice: std_logic;signal totalsum_note1: integer range 0 to 12; -1元纸币总钱数signal totalsum_note5: integer ra
7、nge 0 to 16; -5元纸币总钱数signal totalmoney: integer range 0 to 16; -总投币数signal totalprice: integer range 0 to 18; -实际需要钱款数signal goods_out: std_logic; -给出商品信号begin-计算1元纸币总钱数模块note1_counting:blockbeginprocess(rst,note1)beginif(rst=1 or hold_cancel=1) then totalsum_note1=0;elsif rising_edge(note1) then to
8、talsum_note1=totalsum_note1+1;end if;end process;end block;-计算5元纸币总钱数模块note5_counting:blockbeginprocess(rst,note5)beginif(rst=1 or hold_cancel=1) then totalsum_note5=0;elsif rising_edge(note5) then totalsum_note5=totalsum_note5+5;end if;end process;end block;-选择商品种类模块select_goods:blockbeginprocess(r
9、st,clk)beginif(rst=1 or hold_cancel=1 or led_out=1) thenled_cola=0;led_hamburger=0;cola_choice=0;hamburger_choice=0;elsif rising_edge(clk) thenif cola=1 thenled_cola=1;cola_choice=1;end if;if hamburger=1 then led_hamburger=1;hamburger_choice=1;end if;end if;end process;end block;-选择购买数目模块select_sum:
10、blockbeginprocess(rst,clk)beginif(rst=1 or hold_cancel=1 or led_out=1) thenled_sum1=0;led_sum2=0;sum1_choice=0;sum2_choice=0;elsif rising_edge(clk) thenif sum1=1 thenled_sum1=1;sum1_choice=1;end if;if sum2=1 then led_sum2=1;sum2_choice=1;end if;end if;end process;end block;-计算所需总钱数模块total_money:bloc
11、kbeginprocess(rst,clk)beginif (rst=1 or hold_cancel=1) then totalprice=0;elsif rising_edge(clk) thenif(cola_choice=1 and sum1_choice=1) then totalprice=2;elsif(cola_choice=1 and sum2_choice=1) then totalprice=4;elsif(hamburger_choice=1 and sum1_choice=1) then totalprice=4;elsif(hamburger_choice=1 an
12、d sum2_choice=1) then totalprice=8;end if;end if;end process;end block;-确定与取消模块ok_or_cancel:blockbeginp1:process(rst,ok)beginif(rst=1 or hold_cancel=1 or led_out=1) then hold_ok=0;led_ok=0;elsif rising_edge(ok) then hold_ok=1;led_ok=1;end if;end process;p2:process(rst,cancel)beginif(rst=1) thenhold_
13、cancel=0;led_cancel=0;elsif rising_edge(cancel) thenhold_cancel=1;led_cancel=1;end if;end process;end block;-退币和计算是否钱款已够模块note_return:blockbeginq1:process(rst,clk)beginif(rst=1 or hold_cancel=1) thentotalmoney=0;money_ok=0;elsif rising_edge(clk) thentotalmoney=totalprice) then money_ok=1;else money_
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 1775. 自动 售货 控制系统 设计 报告
![提示](https://www.31ppt.com/images/bang_tan.gif)
链接地址:https://www.31ppt.com/p-3930001.html