【正文】
s largest puter. Modern human life used in almost every piece of electronic and mechanical products will be integrated single , telephone, calculator, home appliances, electronic toys, handheld puters and puter accessories such as a mouse with a 12 in both the Department of SCM. Personal puter will have a large number of SCM in the work. General car with more than 40 SCM, plex industrial control systems may even have hundreds of SCM in the same time work! SCM is not only far exceeds the number of PC and other puting the sum, or even more than the number of human beingsSingle chip, also known as singlechip microcontroller, it is not plete a certain logic chips, but to a puter system integrated into a to a microputer, and puter than just the lack of a microcontroller I / O devices. General talk: a chip bees a puter. Its small size, light weight, cheap, for the study, application and development of facilities provided. At the same time, learning to use the MCU is to understand the principle and structure of the puter the best choice.SCM and the puter functions internally with similar modules, such as CPU, memory, parallel bus, the same effect as well, and hard disk memory devices, and different is its performance of these ponents were relatively weak many of our home puter, but the price is low , usually not more than 10 yuan you can do with it ...... some control for a class is not very plicated electrical work is enough of. We are using automatic drum washing machine, smoke hood, VCD and so on appliances which could see its shadow! ...... It is primarily as a control section of the core ponentsIt is an online realtime control puter, controlline is that the scene is needed is a stronger antijamming ability, low cost, and this is, and offline puter (such as home PC), the main difference.Single chipMCU is through running, and can be modified. Through different procedures to achieve different functions, in particular special unique features, this is another device much effort needs to be done, some great efforts are very difficult to do. A not very plex functions if the 5039。 inter++。 TL1=(655362765)%256。 if(exter==0) // 負(fù)跳變有效 { IT1=1。 //if(temp=tempamp。 } } }} void timer0() interrupt 1 //等待時間判斷及計時 { //inter=0。 danjia=RdFromROM(0x05)。 while(1) { //fangbo=qufan。 //init()。 //zongjine=qibu+7*danjia+dengdai*danjia3+(licheng/10+1)*danjia。 delay(1000) 。 TR1=1。 //定時50ms //EA=1。 EA=1。 danjia2=RdFromROM(0x02)。 while(!key3)。 } if(key3num==5) //退出功能鍵 { key3num=0。 while(!key1)。 } if(key3num==4) //調(diào)起步價 { // display(0,4,0,qibu)。 while(!key1)。 } if(key3num==3) //調(diào)等待單價 danjia3 { // display(0,3,0,danjia3)。 while(!key1)。 } } display(0,1,0,danjia1)。 delay(5)。 while(!key3)。 wela=0。 wela=0。 P2=0x20。 P2=0x10。 wela=1。 delay(4)。 delay(4)。 dge=danjia0/10。 } } */ void display( uint zongjine0,uint dengdai0,uint licheng0,uint danjia0) //數(shù)碼管//顯示{ uint jshi,jge,jjiao,dengd,lshi,lge,dge,djiao。 I2C _init()。 start()。 stop()。return(temp)。 temp=temp|0x01。uchar temp1=0。 else Sda=0。 delayNOP( )。 delayNOP( )。 delayNOP( ) 。 delayNOP( ) 。_nop_()。j0。//uchar danjia1=11,danjia2=22,danjia3=33,qibu=44,danjiazc。sbit dula=P1^5。sbit key0=P1^0。2. PCB板中如果把鍵盤和顯示器放在芯片和其它電路的反面,這樣封裝成實際產(chǎn)品時可把人機接口留在外面,更人性化,也符合人們的習(xí)慣。調(diào)試完成后在Proteus 上仿真結(jié)果如圖41,42,43,44所示。 { 按鍵處理程序 } } } 計算程序的分析與設(shè)計由于里程和單價都精確的小數(shù)點后一位,而顯示時仍按整數(shù)顯示,只不過人為的加入 amp。首先是一定要對I2C總線時序有較深刻了解后再嘗試編程,第二就是要注意向 AT24C02寫一個字和讀一個字的區(qū)別,當(dāng)從 AT24C02讀數(shù)據(jù)時一定要注意,當(dāng)讀完時從機 AT24C02一定要發(fā)送一個非應(yīng)答信號表示數(shù)據(jù)讀完。在本次設(shè)計中顯示程序利用延時程序,每隔5ms刷新一次,相應(yīng)的數(shù)碼管點亮,顯示一位數(shù)據(jù),利用主函數(shù)內(nèi)的循環(huán),實現(xiàn)動態(tài)掃描顯示,同時根據(jù)數(shù)碼管余輝和人眼暫留現(xiàn)象,給人看上去每個數(shù)碼管總是在亮,以實現(xiàn)動態(tài)顯示。中途等待子程序流程圖如圖33所示。圖31 主程序流程圖 里程計數(shù)中斷程序每當(dāng)霍爾傳感器輸出一個低電平信號,單片機定時器0(工作在計數(shù)模式)就對其計數(shù)一次,相應(yīng)的變量設(shè)為inter就自加1,當(dāng)里程計數(shù)器inter對里程脈沖計滿500次時,對其自身進(jìn)行清零操作,為下一次計數(shù)做準(zhǔn)備,同時進(jìn)入里程計數(shù)中斷服務(wù)程序中,里程變量加1,總金額根據(jù)此時所設(shè)單價做出相應(yīng)的變化。最后延時5ms;依次循環(huán)掃描;利用數(shù)碼管點亮后的余暉和人眼視覺暫留效應(yīng)即可實現(xiàn)動態(tài)顯示。74HC573所對應(yīng)真值表21如表。鍵盤去抖動有專用的延時電路,也有專門的延時芯片,也可以用軟件去抖,考慮到電路的難易程度,從簡化硬件的角度,本次設(shè)計采用軟件去抖動,用一個短延時程序,進(jìn)行鍵盤去抖操作。 3. 要特別注意的是SDA和SCL都是雙向傳輸線,平時均處于高電平備用狀態(tài),只有當(dāng)需要關(guān)閉時才使其鉗制在低電平,且僅在SCL為高電平時數(shù)據(jù)才能傳送,而當(dāng)SCL為低電平時才允許數(shù)據(jù)發(fā)生變化。圖24 AT24C02引腳配置圖圖中RR5 是上拉電阻,其作用是減少AT24C02 的靜態(tài)功耗。A44E霍爾傳感器原理如圖22所示。但當(dāng)其作為I/O使用時,由于輸出屬于開漏電路,無上拉電阻故也無法進(jìn)行高低電平的操作,此時必須接上拉電阻,一般阻值選為10K。圖11系統(tǒng)結(jié)構(gòu)圖 第2章 硬件設(shè)計 單片機最小系統(tǒng)單元主控機系統(tǒng)采用STC公司生產(chǎn)的 STC89C52單片機,它含有512 字節(jié)數(shù)據(jù)存儲器RAM,內(nèi)置8K 的電可擦除FLASH ROM,可重復(fù)編程,大小滿足主控機軟件系統(tǒng)設(shè)計,所以不必再擴展程序存儲器。同時,白天和夜晚價格不同,可以進(jìn)行切換。綜上:基于單片機STC89C52設(shè)計的出租車計價器不僅可方便的用軟件代替硬件,降低成本,具備一般計價器的計算里程和顯示總金額的功能,還具備了掉電保持,白天、夜晚單價切換,并且還可很方便的擴展為速度測試儀,具有很好市場前景。鑒于電子技術(shù)、計算機技術(shù)以及各種更先進(jìn)的仿真軟件的出現(xiàn),使用高級語言如C代替匯編語言進(jìn)行編程和控制已成為現(xiàn)實,也成為一種發(fā)展趨勢。3. 消費類電子產(chǎn)品。系統(tǒng)性能指標(biāo);、行駛里程和總金額;。洛陽理工學(xué)院畢業(yè)設(shè)計(論文)基于STC89C52單片機出租車計價器設(shè)計摘 要隨著城市建設(shè)日益加快,象征著城市面貌的出租車行業(yè)也將加速發(fā)展。通過多次調(diào)試系統(tǒng)性能達(dá)到設(shè)計要求。如空調(diào)機、微波爐、IC卡、汽車電子設(shè)備等。單片機C語言編程相對于MC51匯編語言編程有如下優(yōu)點:1. 對單片機的指令系統(tǒng)不需要有很深的理解就可以編程操作單片機。功能要求1. 設(shè)計一個出租車計價器,并利用霍爾傳感器和單片機內(nèi)集成的計數(shù)器測試出出租車運行里程。白天單價、夜晚單價、等待單價和起步價格都可通過獨立鍵盤進(jìn)行調(diào)節(jié)。芯片外圍電路最高可接入40MHZ的晶振(AT單片機數(shù)值一般為24MHZ)。但P0口不能同時作為地址/數(shù)據(jù)總線和I/O使用。圖22由于AT24C02的數(shù)據(jù)線和地址線是復(fù)用的,采用串口的方式傳送數(shù)據(jù),只用兩根線SCL(時鐘脈沖)和SDA(數(shù)據(jù)/地址),進(jìn)行傳送數(shù)據(jù)時遵守I2C總線協(xié)議。 鍵盤調(diào)整單元當(dāng)單價等信息需要進(jìn)行修改時,就要用到鍵盤。 顯示單元顯示單元由兩個4位8段共陽數(shù)碼管組成,電路連接時,公共端接高電平,因此我們需要點亮哪個發(fā)光二極管只需給哪個二極管陰極送低電平,并采用動態(tài)掃描進(jìn)行顯示[6]。表21 74HC573真值表INPUTOUTPUT LE DQL H LL L XH X XHQ0Z其中 :H—高電平。數(shù)碼管動態(tài)顯示電路如圖27所示。里程中斷子程序如圖32所示。圖33 中途等待中斷子程序流程圖 計算程序計算程序根據(jù)里程數(shù)分別進(jìn)入不同的計算公式。 鍵盤程序鍵盤采用查詢的方式,放在主程序中,當(dāng)有按鍵按下的時候,在相應(yīng)I/O口產(chǎn)生一次低電平,當(dāng)單片機查詢出該低電平后