基于FPGA出租车计价器课设_第1页
基于FPGA出租车计价器课设_第2页
基于FPGA出租车计价器课设_第3页
基于FPGA出租车计价器课设_第4页
基于FPGA出租车计价器课设_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

基于FPGA的出租车计费器课程设计程序设计题目:出租车计费器一、设计实验条件QuartusII7.2二、设计目标1. 实现计费功能。按行驶里程计费,起步价为6.00元,并在车行驶3km后按1.2元/km计费,当计费器达到或超过20元时,每千米加收50%的车费,车停止和暂停时不计费;2. 现场模拟汽车的起动、停止、暂停和换挡等状态;3. 设计数码管动态扫描电路,将车费和路程显示出来,各有两位小数。三、设计报告的内容1. 前言伴随中国经济的腾飞,城市化的进程也随之加快。虽然人们出行的选择趋于多样化,但是出租车作为一种重要的交通工具,也为很多人作为出行的选择。大城市里出租车已经相当普及,但是在中小城市出租车依然处于快速发展的阶段。 出租车的计费方式也在发生变化,由只能显示里程的方式变为现在的自主计费和打印发票及语音提示的智能化方式;根据出租车行业的发展需求,国内许多生产厂商也制造出不同类型的计价器,传统的出租车计费器经过十几年的使用,在稳定性,成本等方面都具有一定的优势。利用FPGA设计出满足出租车不同计费需求的计费器,去满足当地出租车的计费需求。这个课题在实现计费功能的同时,也解决了传统出租车计费器系统的不足。出租车的需求不断的增大,因此,出租车计费器的需求也将不断增大,计程车的服务也显得越来越重要,因此出租车计费器也就应运而生了。2. 设计主体(1)设计原理:假设出租车有启动键、停止键、暂停键和档位键。启动键为脉冲触发信号,当它为一个脉冲是,表示汽车已启动,并根据车速的选择和基本车速发出相应频率的脉冲(计费脉冲)实现车费和路程的计数,同时车费显示起步价;当停止键为高电平时,表示汽车熄火,同时停止发出脉冲,此时车费和路程计数清零;当暂停键为高电平时,表示汽车暂停并停止发出脉冲,此时车费和路程计数暂停;档位键用来改变车速,不同档位对应着不同的车速,同时路程计数的速度也不同。出租车计费器可分为两大模块,即控制模块和译码显示模块,系统框图如图1所示,控制模块实现了计费和路程的技术,并且通过不同的档位控制车速。译码显示模块实现了十进制到4位十进制的转换,以及车费和路程的显示。图1 出租车计费器系统框图(2)步骤: 首先设计taxi计费模块,实现计费功能。起步价为6.00元,并在车行驶3km后按1.2元/km计费,当计费器达到或超过20元时,每千米加收50%的车费,车停止和暂停时不计费。taxi模块程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity taxi isport(clk:in std_logic;-计费时钟start:in std_logic;-汽车起动stop:in std_logic;-汽车停止pause:in std_logic;-汽车暂停speedup:in std_logic_vector(1 downto 0);-档位(4个档位)money:out integer range 0 to 8000;-车费distance:out integer range 0 to 8000);-路程end;architecture one of taxi isbeginprocess(clk,start,stop,pause,speedup)variable money_reg,distance_reg:integer range 0 to 8000;-车费和路程的寄存器variable num:integer range 0 to 9;-控制车速的计数器variable dis:integer range 0 to 100;-千米计数器variable d:std_logic;-千米标志位beginif stop=1then-汽车停止,计费和路程清零money_reg:=0;distance_reg:=0;dis:=0;num:=0;elsif start=1then-汽车起动后,起步价为6元money_reg:=600;distance_reg:=0;dis:=0;num:=0;elsif clkevent and clk=1thenif start=0and speedup=00and pause=0 and stop=0then-1档 if num=9 thennum:=0;distance_reg:=distance_reg+1;dis:=dis+1;else num:=num+1;end if;elsif start=0and speedup=01and pause=0 and stop=0then-2档 if num=9 thennum:=0;distance_reg:=distance_reg+2;dis:=dis+2;else num:=num+1;end if;elsif start=0and speedup=10and pause=0 and stop=0then-3档 if num=9 thennum:=0;distance_reg:=distance_reg+5;dis:=dis+5;else num:=num+1;end if;elsif start=0and speedup=11and pause=0 and stop=0then-4档 distance_reg:=distance_reg+1;dis:=dis+1;end if;if dis=100 thend:=1;dis:=0;else d:=0;end if;if distance_reg=300 then-如果超过3km按1.2元/千米计算 if money_reg=2000 and d=1thenmoney_reg:=money_reg+180;-当计费器达到20元,每千米加收50%的车费 end if;end if;end if;money=money_reg;distance=distance_reg;end process;end; 将输出的费用和路程作为输入,给decoder模块,完成数码管显示功能,并且对小数点等做出明确定义。decoder程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity decoder isport(clk20mhz:in std_logic;-系统时钟20MHZmoney_in:in integer range 0 to 8000;-车费distance_in:in integer range 0 to 8000;-路程scan:out std_logic_vector(7 downto 0);-数码管地址选择信号seg7:out std_logic_vector(6 downto 0);-7段显示控制信号(abcdefg) dp:out std_logic);-小数点end;architecture one of decoder issignal clk1khz:std_logic;-1KHZ的分频时钟,用于扫描数码管地址 signal data:std_logic_vector(3 downto 0);signal m_one,m_ten,m_hun,m_tho:std_logic_vector(3 downto 0);-钱数的4位十进制表示signal d_one,d_ten,d_hun,d_tho:std_logic_vector(3 downto 0);-路程的4位十进制表示begin-1KHZ分频,用于扫描数码管地址-process(clk20mhz)variable count:integer range 0 to 9999;beginif clk20mhzevent and clk20mhz=1thenif count=9999 then clk1khz=not clk1khz;count:=0;else count:=count+1;end if;end if;end process;-将车费的十进制数转化为4位十进制数-process(clk20mhz,money_in)variable comb1:integer range 0 to 8000;variable comb1_a,comb1_b,comb1_c,comb1_d:std_logic_vector(3 downto 0); beginif clk20mhzevent and clk20mhz=1thenif comb1money_in thenif comb1_a=9 and comb1_b=9 and comb1_c=9 thencomb1_a:=0000;comb1_b:=0000;comb1_c:=0000;comb1_d:=comb1_d+1;comb1:=comb1+1;elsif comb1_a=9 and comb1_b=9 thencomb1_a:=0000;comb1_b:=0000;comb1_c:=comb1_c+1;comb1:=comb1+1;elsif comb1_a=9 thencomb1_a:=0000;comb1_b:=comb1_b+1;comb1:=comb1+1;elsecomb1_a:=comb1_a+1;comb1:=comb1+1;end if;elsif comb1=money_in thenm_one=comb1_a;m_ten=comb1_b;m_hun=comb1_c;m_thomoney_in thencomb1_a:=0000;comb1_b:=0000;comb1_c:=0000;comb1_d:=0000;comb1:=0;end if;end if;end process;-将路程的十进制转化为4位十进制数-process(clk20mhz,distance_in)variable comb2:integer range 0 to 8000;variable comb2_a,comb2_b,comb2_c,comb2_d:std_logic_vector(3 downto 0); beginif clk20mhzevent and clk20mhz=1thenif comb2distance_in thenif comb2_a=9 and comb2_b=9 and comb2_c=9 thencomb2_a:=0000;comb2_b:=0000;comb2_c:=0000;comb2_d:=comb2_d+1; comb2:=comb2+1;elsif comb2_a=9 and comb2_b=9 then comb2_a:=0000; comb2_b:=0000; comb2_c:=comb2_c+1; comb2:=comb2+1; elsif comb2_a=9 thencomb2_a:=0000;comb2_b:=comb2_b+1; comb2:=comb2+1; elsecomb2_a:=comb2_a+1; comb2:=comb2+1; end if;elsif comb2=distance_in thend_one=comb2_a;d_ten=comb2_b;d_hun=comb2_c;d_thodistance_in thencomb2_a:=0000;comb2_b:=0000;comb2_c:=0000;comb2_d:=0000;comb2:=0;end if;end if;end process;-数码管动态扫描process(clk1khz,m_one,m_ten,m_hun,m_tho,d_one,d_ten,d_hun,d_tho) variable cnt:std_logic_vector(2 downto 0);beginif clk1khzevent and clk1khz=1thencnt:=cnt+1;end if;case cnt iswhen000=data=m_one;dp=0;scandata=m_ten;dp=0;scandata=m_hun;dp=1;scandata=m_tho;dp=0;scandata=d_one;dp=0;scandata=d_ten;dp=0;scandata=d_hun;dp=1;scandata=d_tho;dp=0;scanseg7seg7seg7seg7seg7seg7seg7=;图4 连接电路图 对各模块进行波形仿真,直观看到模块的功能及现象。图5 taxi模块波形仿真图6 decoder模块波形仿真3. 对仿真结果进行分析(1).对控制模块taxi进行仿真后得到的功能仿真结果如图5所示。观察波形可知,当起动键(start)为一个脉冲时,表示汽车已起动,车费money显示起步价6.00元,同时路程distance随着计费脉冲

温馨提示

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

评论

0/150

提交评论