【基于51單片機的出租車計價系統的設計6000字(論文)】_第1頁
【基于51單片機的出租車計價系統的設計6000字(論文)】_第2頁
【基于51單片機的出租車計價系統的設計6000字(論文)】_第3頁
【基于51單片機的出租車計價系統的設計6000字(論文)】_第4頁
【基于51單片機的出租車計價系統的設計6000字(論文)】_第5頁
已閱讀5頁,還剩24頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

蘇州高博軟件技術職業學院畢業設計(論文)報告參考文獻程民利.基于霍爾傳感器的高精度測速電路設計[J].電子設計工程,2013,21(8):109-111楊建潮.出租汽車計價器的計價原理[J].檢定與規程,2011,(2):44-45黃代福.出租車計價器傳感器原理及檢測[J].計量與檢測技術,2016,(8):20-21李平,周原.基于AT89C51和DDS技術的信號發生器設計[J].電子設計工程.2014(10)王翠.基于單片機的出租車計價系統設計[J].現代電子技術.2012(05)姚利彬,許勇,潘明.基于AT89C51的出租車計費系統的設計與實現[J].電子設計工程.2011(23)曹公正,陳娟,張寶利,陳乾輝.AT89C51在出租車記費器上的研究與設計[J].長春工業大學學報(自然科學版).2014(03)陳英梅,席亮亮.基于AT89C51的多種分頻設計與實現[J].電子元器件應用.2015(06)附錄總電路圖主程序:#include<reg52.h>#include<intrins.h>#include<AT24C02.h>#defineucharunsignedchar#defineuintunsignedint ucharcodetable_du[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};ucharcodetable_we[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; uchartt,aa;ucharquanshu;ucharsecond,minute;uintround;ucharround_24c02[2];uintdistance;uintprice,cost;uintwait;ucharqian,bai,shi,ge;sbitkey0=P3^1;sbitkey1=P3^0;sbitkey2=P1^7;sbitkey3=P1^6;sbitkey4=P1^5;sbitled0=P1^0;sbitled1=P1^1;sbitled2=P1^2;sbitled3=P1^3;sbitled4=P1^4;bit key0_flag;bit key1_flag;bit key2_flag;bit key3_flag;bit flag;voiddelayms(unsignedintc){ unsignedcharb; for(;c>0;c--) for(b=110;b>0;b--);}voiddelay_dis(void){ unsignedcharb,c; for(c=7;c>0;c--) for(b=110;b>0;b--);} voidinit_data(void){ distance=0; cost=0; round=0; second=0; minute=0; key0_flag=0; key1_flag=0; key2_flag=1; key3_flag=0; flag=1;}voidjisuan(void){wait=minute*60+second; distance=round+wait/30; if(key1_flag) price=15; else price=20; if(distance<=30) cost=50; else cost=price*(distance-30)/10+50;}voidfenli(uinttemp){ if(temp>9999) temp=9999; qian=temp/1000; bai=temp/100%10; shi=temp%100/10; ge=temp%10;}voidwrite(void){ round_24c02[0]=round&0x00ff; round_24c02[1]=(round>>8)&0x00ff; write_24c02(0x00,key0_flag); write_24c02(0x01,key1_flag); write_24c02(0x02,key2_flag); write_24c02(0x03,key3_flag); write_24c02(0x04,second); write_24c02(0x05,minute); write_24c02(0x06,round_24c02[0]); write_24c02(0x07,round_24c02[1]);}voidread(void){ key0_flag=read_24c02(0x00); key1_flag=read_24c02(0x01); key2_flag=read_24c02(0x02); key3_flag=read_24c02(0x03); second=read_24c02(0x04); minute=read_24c02(0x05); round_24c02[0]=read_24c02(0x06); round_24c02[1]=read_24c02(0x07); round=round_24c02[1]; round=(round<<8 )|round_24c02[0];}voiddisplay(void){ uinttemp; if(key2_flag) { fenli(distance); P2=table_we[7]; P0=table_du[ge]; delay_dis(); P2=table_we[6]; P0=table_du[shi]|0x80; delay_dis(); P2=table_we[5]; P0=table_du[bai]; delay_dis(); P2=table_we[4]; P0=table_du[qian]; delay_dis(); } else { temp=minute*100+second; fenli(temp); P2=table_we[7]; P0=table_du[ge]; delay_dis(); P2=table_we[6]; P0=table_du[shi]; delay_dis(); P2=table_we[5]; P0=table_du[bai]|0x80; delay_dis(); P2=table_we[4]; P0=table_du[qian]; } fenli(cost); P2=table_we[3]; P0=table_du[ge]; delay_dis(); P2=table_we[2]; P0=table_du[shi]|0x80; delay_dis(); P2=table_we[1]; P0=table_du[bai]; delay_dis(); P2=table_we[0]; P0=table_du[qian]; led0=key0_flag; led1=!key1_flag; led2=key2_flag; led3=!key3_flag; led4=flag;}voidkeyscan(void){ if(key0==0) { delayms(10); if(key0==0) { key0_flag=!key0_flag; if(!key0_flag) init_data(); while(!key0); } } if(key1==0) { delayms(10); if(key1==0) { key1_flag=!key1_flag; while(!key1); } } if(key2==0) { delayms(10); if(key2==0) { key2_flag=!key2_flag; while(!key2); } } if(key3==0) { delayms(10); if(key3==0) { key3_flag=!key3_flag; if(key3_flag) { EX0=0; TR0=0; } else { EX0=1; TR0=1; } while(!key3); } } if(key4==0) { delayms(10); if(key4==0) { read(); while(!key4); } }}voidmain(void){ init_data(); TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; ET0=1; IT0=0; EA=1; EX0=1; TR0=1; while(1) { keyscan(); jisuan(); write(); display(); } }voidzd(void)interrupt0{ aa++; if(flag) { quanshu++; if(quanshu>=57) { round++; quanshu=0; } } }voidtimer0(void)interrupt1{ TH0=(65536-50000)/256; TL0=(65536-50000)%256; tt++; if(tt>=20) { tt=0; if(aa<=5)flag=0; elseflag=1; aa=0; if(!flag) { second++; if(second==60) { minute++; second=0; } } }}#include<AT24C02.h>#definesomenop{_nop_();_nop_();_nop_();_nop_();_nop_();}#defineSlaveAddrW0xAE //0xae,a0#defineSlaveAddrR0xAF //0xaf,a1sbitSDA=P3^6;/*數據線*/sbitSCL=P3^7;/*時鐘線*/voidIIC_Start(void){ SDA=1; SCL=1; somenop; SDA=0; somenop; SCL=0; }voidIIC_Stop(void){ SDA=0; SCL=1; somenop; SDA=1;}voidIIC_Ack(bitackbit){ if(ackbit) { SDA=0; } else { SDA=1; } somenop; SCL=1; somenop; SCL=0; SDA=1; somenop;}bitIIC_WaitAck(void){ SDA=1; somenop; SCL=1; somenop; if(SDA) { SCL=0; IIC_Stop(); return0; } else { SCL=0; return1; }}voidIIC_SendByte(unsignedcharbyt){ unsignedchari; for(i=0;i<8;i++) { if(byt&0x80) { SDA=1; } else { SDA=0; } somenop; SCL=1; byt<<=1; somenop; SCL=0; }}unsignedcharIIC_RecByte(void){ unsignedcharda; unsignedchari; for(i=0;i<8;i++) { SCL=1; somenop; da<<=1; if(SDA) da|=0x01; SCL=0; somenop; } returnda;}unsignedcharread_24c02(unsignedcharadd){ unsignedchartemp; IIC_Start(); IIC_SendByte(0xa0); IIC_WaitAck(); IIC_SendByte(add); IIC_WaitAck();

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論