基于单片机出租车计费器的设计系、部:电气与信息工程系专业:通信技术1摘要本设计的是一个基于单片机AT89S52的出租车自动计费设计,附有复位电路,时钟电路,键盘电路等。复位电路是单片机的初始化操作,除了正常的初始化外,为摆脱困境,通过复位电路可以重新开始。时钟电路采用12MHz的晶振,作为系统的时钟源,具有较高的准确性。在上电时字符型液晶1602显示最初的起步价,里程收费,等待时间收费三种收费,通过按键可以调整起步价,里程收费,等待时间收费。通过按键模拟出租车的运行,暂停,停止。在1602液晶上可以显示运行的时间,运行时暂停的时间,通过计算可以得出总共的费用和总的路程。在这里主要是以AT89S52单片机为核心控制器,P0口接1602液晶显示模块,P1口接按键的,通过按键输入。关键字AT89S52;1602液晶;出租车计费器ABSTRACTThedesignisbasedonamonolithicintegratedcircuitAT89S52taxibillingdesign,withresetcircuit,clockingcircuit,keyboardcircuit.Resetcircuitisinitialized,besidesthenormaloperationoftheinitialdilemma,asaforeigner,throughtheresetcircuitcanstartagain.12MHzadoptstheclockcircuit,asasystemofcrystaloscillator,higherclocksource.Thecharactersinthecrystalthattheinitial1602,charges,feesmileagewaitingtime,threebuttonscanbeadjustedbychargingfees,justwaitingtime,mileage.Throughthesimulationofthetaxi,buttons,stop.SuspensionIntheliquidcrystaldisplaycanrun1602,operationtime,whensuspensioncanbeobtainedbythecomputationofthetotalcost.hereismainlyforthecorecontroller,AT89S52SCMP0mouthafter1602LCDmodule,P1mouthafterthekeys,throughthekeystroke.Keyword:AT89S52;1602LCD;Taxidevices2目录1课程设计书·······················································································31.1课程设计任务············································································31.2功能要求···················································································31.3课程设计方案············································································32硬件电路设计····················································································52.1振荡电路设计············································································42.2复位电路设计·············································································42.3键盘接口电路·············································································62.4显示电路···················································································62.5直流电机电路·············································································72.6单片机各引脚功能说明································································72.7L298和1602液晶的简介·····························································93软件设计·························································································133.1单片机资源··············································································133.2单片机模块··············································································133.3系统程序流程框图····································································164proteus调试····················································································174.1proteus介绍··············································································174.2proteus界面介绍·······································································174.3protues的简单使用····································································184.4仿真结果···················································································20心得体会······························································································21参考文献······························································································22致谢····································································································23附录1元件清单···················································································24附录2程序清单···················································································25附录3原理图······················································································3331课程设计任务书1.1课程设计任务设计一个出租车自动计费器,计费包括起步价、行车里程计费、等待时间计费三部分,用1602液晶显示总金额,运行时间,暂停时间,最大值为99.9元,起步价为5.0元,3Km之内起步价计费,超过3Km,设速度为100m/s,10s增加1.3元(即1KM增加1.3元),等待时间单价为每分钟1.5元,用液晶显示总里程,同时用液晶显示等待时间和运行花费时间。设计要求:一、计费功能费用的计算是按行驶里程收费。设起步价为5.00元。1、当里程3km时,按起价计算费用2、当里程3km时,每公里按1.3元计费3、等待累计时间2min时,按1.5元/min计费二、显示功能1、显示行驶里程:用四位数字显示,显示方式为“XXXX”,单位为km。计程范围0-99km,精确到1km。2、显示等候时间:用两位数字显示,显示方式为“XX”,单位为min。计时范围0-59min,精确到1min。3、显示总费用:用四位数字显示,显示方式为“XXX.X”,单位为元。计价范围0-999.9元,精确到0.1元。1.2功能要求本出租车自动计费,上电后显示最初的起步价,里程计费单价,等待时间计费单价,通过按键可以调节起步价,里程计费单价,等待时间计费单价。同时具有运行,暂停,停止等状态,可以显示运行的时间,同时可以显示暂停的时间,具有累加功能,暂停和运行时间在暂停和运行前一次的状态上计时。出租车停止后能够显示行驶的总费用。1.3课程设计方案方案一:采用数字电子技术,利用555定时芯片构成多谐振荡器,或采用外围的晶振电路作为时钟脉冲信号,采用计数芯片对脉冲尽心脉冲的计数和分频,最后通过译码电路对数据进行译码,将译码所得的数据送给数码管显示,一下是4该方案的流程框图,方案一如图1.1所示:图1.1方案一案二:采用EDA技术,根据层次化设计理论,该设计问题自顶向下可分为分频模块,控制模块计量模块、译码和动态扫描显示模块,其系统框图如图1.2所示:图1.2方案二方案三:采用MCU技术,通过单片机作为主控器,利用1602字符液晶作为显示电路,采用外部晶振作为时钟脉冲,通过按键可以方便调节,一下是方案三的系统流程图,本方案主要是必须对于数字电路比较熟悉,成本又高。方案图如图1.3所示:图1.3方案三方案总结:通过各个方案的比较本次采用方案三,不但控制简单,而且成本计时,计费,译码等待信号时钟脉冲计费脉冲公里脉冲数码管显示AT89S52电源电路按键电路直流电机1602液晶LED灯5低廉,设计电路简单。2硬件电路设计2.1振荡电路单片机内部有一个高增益、反相放大器,其输入端为芯片引脚XTAL1,其输出端为引脚XTAL2。通过这两个引脚在芯片外并接石英晶体振荡器和两只电容(电容和一般取33pF)。这样就构成一个稳定的自激振荡器。振荡电路脉冲经过二分频后作为系统的时钟信号,再在二分频的基础上三分频产生ALE信号,此时得到的信号时机器周期信号。振荡电路如图2.1所示:图2.1振荡电路2.2复位电路设计复位操作有两种基本形式:一种是上电复位,另一种是按键复位。按键复位具有上电复位功能外,若要复位,只要按图中的RESET键,电源VCC经电阻R1、R2分压,在RESET端产生一个复位高电平。上电复位电路要求接通电源后,通过外部电容充电来实现单片机自动复位操作。上电瞬间RESET引脚获得高电平,随着电容的充电,RERST引脚的高电平将逐渐下降。RERST