多功能出租车运营控制器

上传人:仙*** 文档编号:120127069 上传时间:2022-07-16 格式:DOC 页数:31 大小:853.50KB
收藏 版权申诉 举报 下载
多功能出租车运营控制器_第1页
第1页 / 共31页
多功能出租车运营控制器_第2页
第2页 / 共31页
多功能出租车运营控制器_第3页
第3页 / 共31页
资源描述:

《多功能出租车运营控制器》由会员分享,可在线阅读,更多相关《多功能出租车运营控制器(31页珍藏版)》请在装配图网上搜索。

1、多功能出租车运营控制器 学号:61007211 姓名:洪立俊1、申请题目:多功能出租车运营控制器这是一个以出租车计费为主要功能的基于FPGA的全数字系统,同时此系统还附加有一些相关的其他功能,比如计时,自动收费,管理员操作等。2、课题背景:出租车是人们日常生活中不可或缺的交通工具,但就目前的出租车运营状况来看,仍存在许多问题,比如司机乱收费,不打表现象较多,出租车公司对于运营信息的管理不到位,另外在客运安全方面仍存在较大漏洞,针对以上提到的问题,我觉得开发一个能够高效管理出租车运营的系统。3、项目规划: n 系统功能:此系统的功能主要有计时(附有闹钟和日期),运营计价,自动收费,运营信息保存,

2、管理员操作等。n 指标及规模:时间显示包括时,分,秒,日期显示包括日,月(分大小月,二月假设为29天),闹钟设置精确到秒,闹铃长达30s。收费标准:白天(6时到夜间23点)起步价为9元,315公里每公里1元,15公里以上每公里1.5元,每等待1分钟加收2元,夜间起步价10元,超过3公里每公里1.8元,每等待1分钟3元。计价按每100米计价,里程增加。里程最大为99公里,收费最大999.99元,自动收费接受10,5元,1元,自动找零找都是1元。系统涉及密码为6位。n 面板(显示):6个8段数码管,44小键盘,开关若干,LED灯n 操作及规则:复位后进入计时,按C修改时间,中途按B可退出,完成六位

3、修改后按E确认,按6进入设置闹钟状态,类似于时间的修改。闹钟时间到或者按0关闭,或者30s后自动关闭。按4显示日期,按C修改日期,类似时间修改。按B回到时间显示。按A进入登陆过程,输入6为密码,登录成功进入,管理员操作程序,按D修改里程分配参数,按F可阅读运营记录。按B退出管理员操作,按F键进入运营过程,按方向键可切换里程和费用的显示,按2进入等待。按3保存记录,进入自动收费,通过拨开关进行收费。收完费进入自动找零至零。按E回到时间显示。n 输入、输出接口:键盘有扫描译码模块,数码管有译码模块及显示驱动模块,相当于数据选择器。4、实现方案: n 核心问题:状态的控制及转移,数据处理模块的设计,

4、以及若干显示的分时显示模块的设计。n 解决方案:FPGA设计顶层文件采用图形化设计,状态机及相关数据处理单元,附加模块部分采用VHDL语言设计,部分采用图形化设计。由于显示部分也是比较复杂的,所以也引进状态的概念对显示内容进行控制。存储器采用数组的形式存储二进制信息,数组元素即为逻辑值向量。5、系统结构:n 系统框图:n 模块功能描述:输入接口用于译码产生相关的控制信号,状态机用于控制不同时刻的相关操作,数据处理单元用来处理相关信号,包括计时模块,相关寄存模块,计费,收费,计程模块,存储器模块等,输出驱动模块用于控制不同时候的输出。n 模块接口标注:输入模块接口有4位键盘码keyvalue输出

5、,握手信号pressed,以及一些经消抖同步的外部输入,如复位reset,闹钟开关控制alarm_on,收费脉冲输入f10,f5,f1,状态机产生控制信号,修改时间,日期使能timeload, dateload,修改密码使能,存储记录使能store,运营控制信号showXX,阅读记录信号readXX,找零信号等。数据处理模块产生时间time,日期date,密码code,里程kilo,收费charge,存储器记录输出record等。输出模块输入包括显示状态控制信号ss,各数据处理单元的显示输出内容,输出为6个8段数码管的信号,和一个闹钟到信号alarmsignal。6、状态流程图:n 系统工作状

6、态流程 由于系统比较庞大,操作过程比较多,所以涉及的状态控制也比较多,为了更加清楚地表示各状态间的控制转移,以及不同状态对应的控制输出信号,现采用多状态机的描述方法。包括主流程图,各子流程图,其中一些具有类似功能的流程就省略了,比如校准日期,设置闹钟,设置参数的流程就和校准时间的流程类似。1. 总流程图:2. 出租车运营流程图3. 校准时间流程图: 4. 管理员登录流程: 5.管理员修改密码流程6. 管理员阅读运营记录流程图:7、程序清单 由于本系统的复杂性,所以程序比较多,这里仅列出主要的程序,同一个程序中类似的代码则省略,具有类似功能的代码仅举其一。 -键盘译码,按键动作标志生成模块-li

7、brary ieee;use ieee.std_logic_1164.all;entity key_decoder isport(col3,col2,col1,col0:in std_logic; row3,row2,row1,row0:in std_logic; clk,scan_clk:in std_logic; keyvalue:out std_logic_vector(3 downto 0); pressed,stop:out std_logic);end key_decoder;architecture rtl of key_decoder issignal temp:std_log

8、ic_vector(7 downto 0);signal temp_pressed:std_logic;signal q1,q2,q3,q4,q5,q6:std_logic;signal keypressed_asy:std_logic;begintempkeyvalue=0000; temp_pressedkeyvalue=0001; temp_pressedkeyvalue=1101; temp_pressedkeyvalue=1110; temp_pressedkeyvalue=1111; temp_pressedtemp_pressed=0; end case;end process;

9、process(scan_clk) -按键动作标志消抖begin if(scan_clkevent and scan_clk=1) then q1=temp_pressed; q2=q1; q3=q2; q4=q3; end if;keypressed_asy=q1 or q2 or q3 or q4;end process;process(clk) -按键动作标志与全局时钟同步化begin if(clkevent and clk=1) then q5=keypressed_asy; q6=q5; end if; pressed=q5 and not(q6);end process;stop=

10、col3 and col2 and col1 and col0;end rtl;-里程计数模块-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity kilocounter isport(start,mile,pause:in std_logic; -开始计数,里程脉冲输入,暂停使能输入端 kilo:out std_logic_vector(11 downto 0); -公里数输出端 high_3,high_15:out std_logic); -大于三公里,大于15公里的使能输出端 end k

11、ilocounter;architecture rtl of kilocounter issignal k1,k0,k00:std_logic_vector(3 downto 0);beginprocess(start,pause,mile)begin if start=0 then -未进入里程计数时里程数始终保持为零 k1=0000;k0=0000;k00=0000; high_3=0;high_15=0; else if pause=1 then -等待状态下保持里程数 k1=k1;k0=k0;k00=k00; elsif rising_edge(mile) then -在里程脉冲下正常

12、计数 if k00=1001 then k00=0000; if k0=1001 then k0=0000; if k1=1001 then k1=0000; else k1=k1+1; end if; else k0=k0+1; end if; else k00=0011 then -达到里程要求时标志信号有效 high_3=0010 or (k1=0001 and k0=0101) then high_15=1;end if;end process;kilo(11 downto 8)=k1;kilo(7 downto 4)=k0;kilo(3 downto 0)clk, clk1s=clk

13、1s);process(clk1s,clk,reset,timeload)begin if reset=0 then -复位清零 temp_time5=0000;temp_time4=0000;temp_time3=0000;temp_time2=0000;temp_time1=0000;temp_time0=0000; elsif rising_edge(clk) then if timeload=1 then -修改时间时置数 temp_time5=buffertime(23 downto 20); temp_time4=buffertime(19 downto 16); temp_tim

14、e3=buffertime(15 downto 12); temp_time2=buffertime(11 downto 8); temp_time1=buffertime(7 downto 4); temp_time0=buffertime(3 downto 0); else -正常计时 if clk1s=1 then if temp_time0=1001 then temp_time0=0000; if temp_time1=0101 then temp_time1=0000; if temp_time2=1001 then temp_time2=0000; if temp_time3=0

15、101 then temp_time3=0000; if temp_time4=1001 and temp_time5=0000 then temp_time4=0000;temp_time5=0001; elsif temp_time4=1001 and temp_time5=0001 then temp_time4=0000;temp_time5=0010; elsif temp_time4=0011 and temp_time5=0010 then temp_time4=0000;temp_time5=0000; else temp_time4=temp_time4+1; end if;

16、 else temp_time3=temp_time3+1; end if; else temp_time2=temp_time2+1; end if; else temp_time1=temp_time1+1; end if; else temp_time0=temp_time0+1; end if; end if; end if; end if;-当计到23:59:59出现进位信号至日月模块- if temp_time5&temp_time4&temp_time3&temp_time2&temp_time1&temp_time0=001000110101100101011001 then

17、ci=1; else ci=0; end if;end process;time(23 downto 20)=temp_time5;time(19 downto 16)=temp_time4;time(15 downto 12)=temp_time3;time(11 downto 8)=temp_time2;time(7 downto 4)=temp_time1;time(3 downto 0)=temp_time0;end rtl;-计费模块-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use i

18、eee.std_logic_unsigned.all;entity total_charge isport(start,pause,mile,f_wait:in std_logic; -未运营状态,等待暂停状态,里程脉冲,等待时间脉冲 high_3,high_15:in std_logic; -里程标志输入 time:in std_logic_vector(23 downto 0); -时间输入 charge:out std_logic_vector(19 downto 0);-计费总价输出,分别为百,十,个,十分,百分位end total_charge;architecture rtl of

19、 total_charge issignal c4,c3,c2,c1,c0:std_logic_vector(3 downto 0);beginprocess(time,pause,start,mile,f_wait,high_3,high_15)variable hour_h,hour_l:std_logic_vector(3 downto 0);beginhour_h:=time(23 downto 20);hour_l:=time(19 downto 16); if start=0 then -未运营时价格总为零 c4=0000;c3=0000;c2=0000;c1=0000;c0=01

20、10) or hour_h=0001 or (hour_h=0010 and hour_l=0010) then -白天运营 if pause=1 then -等待下的计费 if rising_edge(f_wait) then -即pause=1进入等待状态 if c2=1001 or c2=1000 then if c2=1001 then c2=0001; else c2=0000; end if; if c3=1001 then c3=0000; if c4=1001 then c4=0000; else c4=c4+1; end if; else c3=c3+1; end if; e

21、lse c2=c2+2; end if; end if; else if rising_edge(mile) then -正常运营 if high_3=0 then c4=0000;c3=0000;c2=1001;c1=0000;c0=0000; elsif high_15=0 then if c1=1001 then c1=0000; if c2=1001 then c2=0000; if c3=1001 then c3=0000; if c4=1001 then c4=0000; else c4=c4+1; end if; else c3=c3+1; end if; else c2=c2+

22、1; end if; else c1=c1+1; end if; elsif high_3=1 and high_15=1 then if(c0=0101 and c1=1000)or c1=1001 then if c1=1001 and c0=0101 then c0=0000;c1=0001; elsif c1=1001 and c0=0000 then c0=0101;c1=0000; elsif c1=1000 and c0=0101 then c0=0000;c1=0000; end if; if c2=1001 then c2=0000; if c3=1001 then c3=0

23、000; if c4=1001 then c4=0000; else c4=c4+1; end if; else c3=c3+1; end if; else c2=c2+1; end if; elsif c0=0000 then c0=0101;c1=c1+1; else c0=0000;c1=c1+0010; end if; end if; end if; end if; else -夜间运营模式 if pause=1 then if rising_edge(f_wait) then 省略部分end process;charge(19 downto 16)=c4;charge(15 down

24、to 12)=c3;charge(11 downto 8)=c2;charge(7 downto 4)=c1;charge(3 downto 0)=c0;end rtl;-铃声产生模块-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity bell_pro isport(alarm_on,clk,alarm_load,pressed:in std_logic; -闹钟开关,时钟,修改置数,键盘响应 buffertime:in std

25、_logic_vector(15 downto 0); -修改时间并行输入端 time:in std_logic_vector(23 downto 0); -当前时间并行输入 keyvalue:in std_logic_vector(3 downto 0); -键盘值输入端 alarm_signal:out std_logic); -闹铃信号输出端end bell_pro;architecture rtl of bell_pro issignal alarm:std_logic;type state is(s0,s1,s2,s3);signal pre_state:state:=s0;sign

26、al next_state:state:=s0;signal iner_ala_time:std_logic_vector(15 downto 0);beginprocess(clk) -修改置数进程begin if rising_edge(clk) then if alarm_load=1 then iner_ala_time=buffertime; end if; end if;end process;process(clk,alarm_on) -状态转移进程begin if alarm_on=0 then pre_state=s0; elsif rising_edge(clk) then

27、 pre_state if iner_ala_time=time(23 downto 8) then next_state=s1; else next_state if pressed=1 and keyvalue=0000 then next_state=0011 then next_state=s2; else next_state if time(7 downto 4)=0000 then next_state=s0; else next_state if time(7 downto 4)=0011 then next_state=s2; else next_statenext_stat

28、e=s0; end case;end process;process(pre_state) -状态输出begin if pre_state=s1 then alarm=1; else alarm=0; end if;end process;alarm_signal=alarm;end rtl;-存储器模块-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity ram_16 isport(clk:in std_logic; wr:in std_logic:=0; -写使能 re:in std

29、_logic:=0; -读使能 re_address,wr_address:in std_logic_vector(3 downto 0);-读写地址输入端 time:in std_logic_vector(23 downto 0);-时间输入 date:in std_logic_vector(15 downto 0);-日期输入 charge:in std_logic_vector(19 downto 0);-费用输入 kilo:in std_logic_vector(11 downto 0);-里程输入 tra_record:out std_logic_vector(55 downto 0

30、);-运营记录输出end ram_16;architecture rtl of ram_16 issubtype ram_word is std_logic_vector(55 downto 0);type ram_table is array(0 to 15) of ram_word;signal ram:ram_table;beginprocess(clk,time,date,charge,re_address,wr_address,kilo,wr,re) begin if rising_edge(clk) then if re=1 then -读出运营记录 tra_record=ram(

31、conv_integer(re_address); elsif wr=1 then -写进记录 ram(conv_integer(wr_address)(55 downto 44)=kilo; ram(conv_integer(wr_address)(43 downto 28)=date; ram(conv_integer(wr_address)(27 downto 12)=time(23 downto 8); ram(conv_integer(wr_address)(11 downto 0)=000000010000 then if f1=1 then if money_temp(3 dow

32、nto 0)=0000 then money_temp(3 downto 0):=1001; if money_temp(7 downto 4)=0000 then money_temp(7 downto 4):=1001; money_temp(11 downto 8):=money_temp(11 downto 8)-1; else money_temp(7 downto 4):=money_temp(7 downto 4)-1; end if; else money_temp(3 downto 0):=money_temp(3 downto 0)-1; end if; elsif f5=

33、1 then if money_temp(3 downto 0)0101 then money_temp(3 downto 0):=money_temp(3 downto 0)-11; if money_temp(7 downto 4)=0000 then money_temp(7 downto 4):=1001; money_temp(11 downto 8):=money_temp(11 downto 8)-1; else money_temp(7 downto 4):=money_temp(7 downto 4)-1; end if; else money_temp(3 downto 0

34、):=money_temp(3 downto 0)-5; end if; elsif f10=1 then if money_temp(7 downto 4)=0000 then money_temp(7 downto 4):=1001; money_temp(11 downto 8):=money_temp(11 downto 8)-1; else money_temp(7 downto 4):=money_temp(7 downto 4)-1; end if; else money_temp:=money_temp; end if; elsif money_temp=00000000010

35、1 then if f10=1 then return_temp:=1010-money_temp(3 downto 0); money_temp:=000000000000; elsif f5=1 then money_temp:=money_temp-000000000101; elsif f1=1 then money_temp:=money_temp-1; else money_temp:=money_temp; end if; elsif money_temp=000000000001 then if f10=1 then return_temp:=1010-money_temp(3

36、 downto 0); money_temp:=000000000000; elsif f5=1 then return_temp:=0101-money_temp(3 downto 0); money_temp:=000000000000; elsif f1=1 then money_temp:=money_temp-1; else money_temp:=money_temp; end if; else money_temp:=000000000000; end if; if clk1s=1 and en_return=1 then if return_temp/=000000000000

37、 then return_temp:=return_temp-1; else return_temp:=return_temp; end if; else return_temp:=return_temp; end if; end if;money=money_temp;return_money=return_temp;end process;end rtl;-总的控制状态机-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity S

38、TATEMACHINE isport(clk,pressed,reset:in std_logic; keyvalue:in std_logic_vector(3 downto 0); codeout:in std_logic_vector(23 downto 0); money:in std_logic_vector(11 downto 0); return_money:in std_logic_vector(3 downto 0); timeload,dateload,alarmload,codeload,paraload,readstate,start,pause,en_return,w

39、rite,dot:out std_logic; ss:out std_logic_vector(5 downto 0); buffertime:out std_logic_vector(23 downto 0); bufferalarm:out std_logic_vector(15 downto 0); bufferdate:out std_logic_vector(15 downto 0); buffernewcode:out std_logic_vector(23 downto 0); buffernewpara:out std_logic_vector(7 downto 0);end

40、STATEMACHINE;architecture rtl of STATEMACHINE istype state is(timecounter,modifytime1,modifytime2,modifytime3,modifytime4,modifytime5,modifytime6,modifytime7,loadtime, setalarm1,setalarm2,setalarm3,setalarm4,setalarm5,loadalarm, showdate,modifydate1,modifydate2,modifydate3,modifydate4,modifydate5,lo

41、addate, inputcode1,inputcode2,inputcode3,inputcode4,inputcode5,inputcode6,inputcode7,compare, hello,setcode1,setcode2,setcode3,setcode4,setcode5,setcode6,setcode7, setcode8,setcode9,setcode10,setcode11,setcode12,setcode13,setcode14,compare_newcode,loadnewcode, setpara1,setpara2,setpara3,loadpara, re

42、addate,readtime,readkilo,readmoney, showkilo,showmoney,waiton,store,getcharge,return_change,holdon);signal pre_state:state:=timecounter; -定义当前状态 -定义状态机内部寄存器,用来修改某些值时用到-signal time_temp:std_logic_vector(23 downto 0); -校时寄存器signal alarm_temp:std_logic_vector(15 downto 0); -闹钟设置寄存器 signal date_temp:std_logic_vector(15 downto 0); -校日期寄存器signal code_temp:std_logic_vector(23 do

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!