基于VHDL编程FPGA的地铁自动售票机_地铁自动售票系统vhdl

其他范文 时间:2020-02-28 19:01:31 收藏本文下载本文
【www.daodoc.com - 其他范文】

基于VHDL编程FPGA的地铁自动售票机由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“地铁自动售票系统vhdl”。

地铁自动售票机

一、设计要求

1、功能描述

用于模仿地铁售票自动售票,完成地铁售票的核心控制功能。

2、功能要求

售票机有两个进币孔,一个是输入硬币,识别的范围是一元硬币;一个是纸币,识别的范围是一元、两元、五元、十元、二十元。乘客可以连续多次投入钱币。乘客 一次只能选择一个出站口,购买车票时,乘客先选出站口,有六个出站口可供选择,再选择所需的票数,然后投币,投入的钱币达到或者超过所需金额时,售票机自 动出票,并找零。本次交易结束后,等待下一次交易。在选择出站口、所需票数以及在投币期间,乘客可以按取消键取消操作,钱币自动退出。

二、实验分析

1、买票时,乘客按下开始键,售票机进入站台选择程序,乘客选择出站口后,可以按取消键重新选择,否则售票机自动进入票数选择程序,同样这时可以按下取消键重新开始选择出站口以及票数。

2、当选择好出站口以及所需票数时,乘客可以投硬币或者用纸币,当所投的钱币总额大于或者等于票价时,售票机自动出票以及找零。期间,可以按下取消键重新开始选择,并退出所有的钱币。

3、乘客若还没选择出站口或者票数,就投币或者使用纸币,售票机会自动退出所有的钱币。

4、有六个站台可供乘客选择,每个乘客最多可以买3张票,六个站台编号为1到6,票价从2元依次递增到7。

三、系统流程图

四、程序源代码 LIBRARY IEEE;USE IEEE.std_logic_1164.ALL;USE IEEE.std_logic_arith.ALL;USE IEEE.std_logic_unsigned.ALL;ENTITY metrosell IS PORT(clk:in std_logic;startselect:in std_logic;sure:in std_logic;save your forward step(s)coin1y:in std_logic;pmoney1y:in std_logic;pmoney2y:in std_logic;pmoney5y:in std_logic;pmoney10y:in std_logic;money pmoney20y:in std_logic;money cancel:in std_logic;number:in std_logic_vector(3 downto 0);the tickets platform:in std_logic_vector(3 downto 0);want to reach moneystorage:out std_logic;acceptmo:out std_logic;stamp:out std_logic;--set the clock signal--start to select the platform--this button is to--1 yuan coin

--1 yuan paper money--2 yuan paper money--5 yuan paper money--10 yuan paper--20 yuan paper--cancel the forward step(s)--choose the number of--choose the platform you--to store the money--accept the money--stamp outgate charge:out std_logic_vector(3 downto 0);--the mount of charge,up to 15 yuan chargegate:out std_logic--charge outgate);END metrosell;ARCHITECTURE sell OF metrosell IS type state_type is(initial_type,selectp_type,selectnum_type,insert_type,stamp_type,charge_type);--define six types signal state:state_type;--define a shared state BEGIN main:proce(clk,state,startselect,platform,number,coin1y,pmoney1y,pmoney2y,pmoney5y,pmoney10y,pmoney20y,cancel,sure)variable univalence :integer range 0 to 7;--the univalence of the ticket variable total_money :integer range 0 to 21;--the price of the ticket(s)variable selectp_alr:std_logic;--the flag of select platform type variable selectnum_alr:std_logic;--the flag of select number type variable stamp_alr:std_logic;--the flag of the stamp gate variable charge_alr:std_logic;--the flag of the charge gate variable money_reg:integer range 0 to 21;--the mount of money put in variable coin1y_f:std_logic;--the flag of one yuan coin variable pmoney1y_f:std_logic;--the flag of one yuan paper money variable pmoney2y_f:std_logic;--the flag of two yuan paper money variable pmoney10y_f:std_logic;--the flag of ten yuan paper money variable pmoney20y_f:std_logic;--the flag of twelve yuan paper money variable pmoney5y_f:std_logic;--the flag of five yuan paper money variable charge_reg:integer range 0 to 15;

begin if(rising_edge(clk))then case state is when initial_type => variables univalence:=0;selectp_alr:='0';selectnum_alr:='0';stamp_alr:='0';charge_alr:='0';money_reg:=0;total_money:=0;coin1y_f:='0';pmoney1y_f:='0';pmoney2y_f:='0';pmoney5y_f:='0';

--the register of charge--initialize some pmoney10y_f:='0';pmoney20y_f:='0';moneystorage if(selectp_alr='0'and cancel='0')then--choose the platform if(platform=“0001”)then univalence:=2;selectp_alr:='1';elsif(platform=“0010”)then univalence:=3;selectp_alr:='1';elsif(platform=“0011”)then univalence:=4;selectp_alr:='1';elsif(platform=“0100”)then univalence:=5;selectp_alr:='1';elsif(platform=“0101”)then univalence:=6;selectp_alr:='1';elsif(platform=“0110”)then univalence:=7;selectp_alr:='1';elsif(platform=“0000”)then univalence:=0;selectp_alr:='0';else null;end if;elsif(selectp_alr='1'and cancel='1')then state--you can buy at most 3 tickets if(selectnum_alr='0'and cancel='0')then--choose the number of tickets if(number=“0001”)then if(univalence=2)then total_money:=2;selectnum_alr:='1';elsif(univalence=3)then total_money:=3;selectnum_alr:='1';elsif(univalence=4)then total_money:=4;selectnum_alr:='1';elsif(univalence=5)then total_money:=5;selectnum_alr:='1';elsif(univalence=6)then total_money:=6;selectnum_alr:='1';elsif(univalence=7)then total_money:=7;selectnum_alr:='1';elsif(univalence=0)then total_money:=0;selectnum_alr:='0';else null;end if;end if;

if(number=“0010”)then if(univalence=2)then total_money:=4;selectnum_alr:='1';elsif(univalence=3)then total_money:=6;selectnum_alr:='1';elsif(univalence=4)then total_money:=8;selectnum_alr:='1';elsif(univalence=5)then total_money:=10;selectnum_alr:='1';elsif(univalence=6)then total_money:=12;selectnum_alr:='1';elsif(univalence=7)then total_money:=14;selectnum_alr:='1';elsif(univalence=0)then total_money:=0;selectnum_alr:='0';else null;end if;end if;if(number=“0011”)then if(univalence=2)then total_money:=6;selectnum_alr:='1';elsif(univalence=3)then total_money:=9;selectnum_alr:='1';elsif(univalence=4)then total_money:=12;selectnum_alr:='1';elsif(univalence=5)then total_money:=15;selectnum_alr:='1';elsif(univalence=6)then total_money:=18;selectnum_alr:='1';elsif(univalence=7)then total_money:=21;selectnum_alr:='1';elsif(univalence=0)then total_money:=0;selectnum_alr:='0';else null;end if;end if;elsif(selectnum_alr='1'and cancel='1')then state moneystorage=total_money)then state--put out the stamp if(stamp_alr='0')then acceptmo--put out the charge charge_reg:=money_reg-total_money;case charge_reg is when 0 => charge charge

when 2 => charge charge charge charge charge charge charge

end case;end if;

when 9 => charge charge charge charge charge charge charge charge0 and charge_alr='0')then chargegate

五、波形仿真

1、乘客按下开始按钮,进入选站台模式,选择二号站台,按下确定键,再选择票数为2张,按下确定键,售票机钱箱关闭,投入一张两元和五元纸币(对顺序没有要求),此时钱币总额大于票价,出两张票并找零一元。之后系统进入初始化状态。具体仿真如图 1 仿真1

图 1 仿真12、测试cancel键,当乘客按正确的操作完成选站台时,按下取消键,再重新选择,如图 2 cancel仿真,仿真波形如下。

图 2 cancel仿真

3、还是测试cancel键,当乘客选择好票数时,按下cancel键,然后重新选择两张单价为七块钱的六号站台票,投入一张20元和5元,找零六元。仿真波形如图 3 cancel仿真2

图 3 cancel仿真24、乘客选择五号站台,两张票,然后先后投入一元纸币,两元纸币,一元纸币,五元纸币,然后按下取消键,售票机自动放出所有的钱币。仿真如图 4 cancel仿真3。

图 4 cancel仿真3

六、心得体会

在我的设计中,有一个moneystorage信号量用于控制储存钱币箱的开与关,这个设计主要考虑到当乘客要求退币时,最好不是从售票机中取出投入的钱数,然后退还,设置了这个开关,就可以在按下取消键时,直接从储存钱币箱中退出钱币。

还有,乘客选择的站台以及票数,在售票机内部会自动将这两个信号传给出票系统,从而自动出票,以上写的程序只是让系统知道怎样收钱以及找零。

这次实验总体上来说比六人抢答器简单,但是因为这个售票机完全是自己写的,所以也不是想象中的那么简单。这也让我看出,要完全自己去做一件东西不是简单的,特别是要考虑很全面,还是要发一些时间的。

地铁自动售票机

自动售票机售票机高1.8米,宽0.95米,厚0.8米。所需要触摸的最高位置为硬币的投币口,高度为1.4米,这个高度是基本可以使残疾人或是具备购票能力的儿童触碰并买到车票的。在机器的......

FPGA编程经验

整个verilog中是以module为编写基本单元的,module不宜过大,目标是实现一些基本功能即可,module的层次不宜太深,一般3-5层即可,给module划分层次原则:实现最基本功能的为底层module,......

LabVIEW FPGA编程小结

LabVIEW FPGA编程小结NI PXI-7813R为FPGA卡,板卡上引出4个端口,每个端口有40路引脚,共160路DIO,使用LabVIEW FPGA模块进行编程控制。当FPGA程序复杂度变大或是使用的DIO端口数增......

VHDL 编程的一些心得体会

VHDL 编程的一些心得体会(转) VHDL 是由美国国防部为描述电子电路所开发的一种语言,其全称为(Very High Speed Integrated Circuit) Hardware Description Language。 与另......

VHDL 编程的一些心得体会

VHDL 编程的一些心得体会(转) http://www.dzjs.net/html/EDAjishu/2007/0131/1504.htmlVHDL 是由美国国防部为描述电子电路所开发的一种语言,其全称为(Very High Speed Inte......

下载基于VHDL编程FPGA的地铁自动售票机word格式文档
下载基于VHDL编程FPGA的地铁自动售票机.doc
将本文档下载到自己电脑,方便修改和收藏。
点此处下载文档

文档为doc格式

热门文章
整站推荐
    点击下载本文