【正文】
//當(dāng)前菜單子菜單的指針 main1_menu[0].parent_menus=NULL。 //開(kāi)始測(cè)量函數(shù), 取消. measure_menu[1].subs=NULL。 break。n++) { draw_bmp(n*2,20,96,0,menu_led[n].display)。 } select_item(user_choosen+1)。 //延時(shí)//ClockMsg()。 store_menu_initial()。 sbit zf=P2^0。 //4 5 6 7 8 9 unsigned int t=0。 //單片機(jī)將DQ拉低 delay(80)。i0。 for (i=8。 }delay(4)。 //跳過(guò)讀序號(hào)列號(hào)的操作 WriteOneChar(0xBE)。 t=t|a。 //十位數(shù) disdata[2]=i%100/10。 P0=0xff。 delay(150)。 delay(150)。 while(1) //主循環(huán) { temp=ReadTemperature()。 //ADC0832 k outsbit ADCLK =P3^2。j10。 ADDI=1。 _nop_()。 _nop_()。 _nop_()。i++) { dat|=ADDO。 if(i==7)dat|=ADDO。 ADCLK=0。//拉低CLK端 ADDO=1。j++) { value[(i+1)*16+j]=table[(*p0x2e)*16+j]。 for(i=128。 tra(dsw)。i++) //sw是154選通開(kāi)關(guān)。 } sw=0。 P2=0x00。s control of the significant progress in recent years. First, the status of the role of As we all know, in today39。s economic and social development of the Tenth FiveYear Plan clearly to the development of instrumentation in an important position. National Program for the Development of Instruments referred to, but in an important position, is the first time since the founding of the PRC. Shortly thereafter, the State Planning Commission, Economic and Trade Commission, Ministry of Science and Technology and many other ministries are listed a number of special, a large amount of money spent to support the development of instrumentation. In 2005, the National Development and Reform Commission issued a formal to revitalize the equipment manufacturing industry to speed up a number of opinions, the various industries in the 16 selected areas of priority to the development of specific legislation to support the development of the first of which is the 11 major projects and sophisticated automation control system testing equipment. In 2006 to develop national longterm scientific and technological development program, involves a number of control and measurement instrumentation development projects. April 2008, Ministry of Science and Technology, National Development and Reform Commission, Ministry of Education and the China Association for Science and Technology have jointly issued the innovative ways to work on strengthening a number of opinions, officially launched the work of innovative ways to carry out in the country. This paper, we explicitly put forward innovative approaches, including creative thinking, innovative approaches and innovative tools for the three elements of the main innovative tools to promote scientific and technological innovation refers to the scientific instruments. The important role of scientific instruments have been further enhanced, more powerful research and development support. In addition, 863 plans, especially in the space program and other national science and technology development plans to support the control and measurement instrumentation has also been on the development of an important position. Is in a very favorable situation, in recent years, China39。 my instrument control and measurement of the basic situation。 delay(5)。 P2=0x00。 //顯示字符,順序是從左掃到右,有16列,數(shù)據(jù)電平是從左1到左16,由低到高 for(i=0。 //AD轉(zhuǎn)換結(jié)果 l=k/*。i16。i++) { if(i4) //i=2時(shí)查的是句號(hào),其他3個(gè)是電壓值 { for(j=0。 } ADCS=1。 _nop_()。 _nop_()。 for(i=0。0x1。0x1。 ADCLK=1。 if(channel==0)channel=2。ic。 //ADC0832 chip seclectsbit ADDI =P3^3。 P2=0xff。 dots=0。 shi=0。 P0=tflag。}void display_temper(unsigned int i){ disdata[0]=i/1000。 //低位右移4位,舍棄小數(shù)部分 //t=b4。 // 啟動(dòng)溫度轉(zhuǎn)換 發(fā)送指令0x44 Init_DS18B20()。 DQ = 1。 } return(dat)。unsigned char dat = 0。 //DQ復(fù)位 delay(8)。sbit DQ =P3^3。sbit led_run=P1^0。 main_menu_initial()。 Disp_Img(FirstPage)。nmax_item。 if (max_item=4) //菜單項(xiàng)為3則表示為主菜單. { for(n=0。 } shuaxin=1。 measure_menu[1].menu_count=2。 //定義一個(gè)開(kāi)始測(cè)量數(shù)組// main1_menu[0].subs=NULL。 TMOD=0x11。感謝指導(dǎo)老師,在他的指導(dǎo)下,我們對(duì)本次設(shè)計(jì)有了深刻的認(rèn)識(shí)和了解,更好的掌握了學(xué)習(xí)和設(shè)計(jì)的方法,同時(shí)他還給我們提供了大量的學(xué)習(xí)參考資料,教會(huì)我們?nèi)绾螐闹R(shí)的海洋中檢索到我們想要的知識(shí),他對(duì)學(xué)習(xí)的嚴(yán)謹(jǐn)態(tài)度也給我們做了良好的榜樣。同時(shí)本設(shè)計(jì)是在Proteus上進(jìn)行仿真,在Keil C軟件上進(jìn)行編程,最后二者聯(lián)調(diào),實(shí)現(xiàn)設(shè)計(jì)任務(wù)的。軟件是基于C語(yǔ)言編寫(xiě)的,結(jié)合C語(yǔ)言編寫(xiě)語(yǔ)言的優(yōu)點(diǎn),使我們的編寫(xiě)具有很好的可控性、模塊化和移植性。6 系統(tǒng)仿真前面已經(jīng)把單片機(jī)系統(tǒng)的硬件設(shè)計(jì)和軟件設(shè)計(jì)完成了,下一步就可以著手進(jìn)行仿真,因?yàn)樵谠O(shè)計(jì)的過(guò)程之中肯定有許多的錯(cuò)誤,需要進(jìn)行仿真來(lái)發(fā)現(xiàn)錯(cuò)誤和調(diào)試錯(cuò)誤。單片機(jī)的功耗隨主振頻率的提高而增加,頻率越高,CMOS管處于放大區(qū)的時(shí)間越長(zhǎng),功耗就越大。 AT89C52的低功耗措施AT89C52單片機(jī)是采用CMOS工藝的低功耗8位單片機(jī)芯片,具有正常、空閑、掉電三種工作狀態(tài)。5 系統(tǒng)低功耗設(shè)計(jì) 設(shè)計(jì)思路系統(tǒng)設(shè)計(jì)的總體思路是圍繞如何實(shí)現(xiàn)低功耗展開(kāi)。機(jī)器匯編是通過(guò)匯編軟件將源程序變?yōu)闄C(jī)器碼,用于MCS51單片機(jī)的匯編軟件有早期的A51,隨著單片機(jī)開(kāi)發(fā)技術(shù)的不斷發(fā)展,從普遍使用匯編語(yǔ)言到逐漸使用高級(jí)語(yǔ)言開(kāi)發(fā),單片機(jī)的開(kāi)發(fā)軟件也在不斷發(fā)展,Keil C軟件是目前最流行開(kāi)發(fā)MCS51系列單片機(jī)的軟件,這從近年來(lái)各仿真機(jī)廠(chǎng)商紛紛宣布全面支持Keil C即可看出。前者可在相當(dāng)程度上得到實(shí)物演示實(shí)驗(yàn)的效果,后者則是實(shí)物演示實(shí)驗(yàn)難以達(dá)到的效果。本系統(tǒng)采用間接控制方式。該型號(hào)顯示器消耗電量比較低,可以滿(mǎn)足系統(tǒng)要求。如果有額外的SCLK周期,它們將被忽略。而通信時(shí),僅需要3個(gè)口線(xiàn):(1)RES(復(fù)位),(2)I/O數(shù)據(jù)線(xiàn),(3)SCLK(串行時(shí)鐘)。⑶ 鍵盤(pán)抖動(dòng)的消除:抖動(dòng)的消除大致可以分為硬件削除抖動(dòng)和軟件削抖。其內(nèi)部電源輸入與參考電壓的復(fù)用,使得芯片的模擬電壓輸入在05V之間。 /CS 片選使能,低電平芯片使能; 工作頻率為250KHZ,轉(zhuǎn)換時(shí)間為32us;( 模數(shù)轉(zhuǎn)換電路圖)這類(lèi)型ADC的分辨率和采樣速率是相互牽制的。本設(shè)計(jì)中復(fù)位電路采用的是開(kāi)關(guān)復(fù)位電路,開(kāi)關(guān)S9未按下是上電復(fù)位電路,上電復(fù)位電路在上電的瞬間,由于電容上的電壓不能突變,電容處于充電(導(dǎo)通)狀態(tài),故RST腳的電壓與VCC相同。因此,任何單片機(jī)在開(kāi)始工作前,都必須進(jìn)行一次復(fù)位過(guò)程,使單片機(jī)處于一種確定的狀態(tài)。 單片機(jī)最小系統(tǒng)的實(shí)現(xiàn)介紹完以上的單片機(jī)系統(tǒng)的核心芯之后,我們采用AT89C52來(lái)實(shí)現(xiàn)一個(gè)單片機(jī)系統(tǒng)能運(yùn)行起來(lái)的需求最小的系統(tǒng),電路圖如下所示:( 單片機(jī)的最小系統(tǒng)圖)上圖由晶振電路和復(fù)位電路,AT89C52芯片組成,構(gòu)成最小的單片機(jī)系統(tǒng), 下面詳細(xì)介紹其中的兩個(gè)電路。欲使CPU訪(fǎng)問(wèn)外部程序存儲(chǔ)器(地址為 0000HFFFH),EA端必須保持低電平(接地)。(表32 P3口第二功能)端口引腳第二功能RXD(串行輸入口)TXD(串行輸出口)INT0(外中斷0)INT1(外中斷1)T0(定時(shí)/計(jì)數(shù)器0)T1(定時(shí)/計(jì)數(shù)器1)WR(外部數(shù)據(jù)存儲(chǔ)器寫(xiě)選通)RD (外部數(shù)據(jù)存儲(chǔ)器讀選通) 對(duì)Flash存儲(chǔ)器編程器件,改引腳還用于輸入編程脈沖(PROG)。P3口作為一般的I/O口線(xiàn)外,更重要的用途是它的第二功能,如表32所示:此外,P3口還接收一些用于Flash閃速存儲(chǔ)器編程和程序校驗(yàn)的控制信號(hào)。 在訪(fǎng)問(wèn)外部程序存儲(chǔ)器或16位地址的外部數(shù)據(jù)存儲(chǔ)器(例如執(zhí)行MOVDPTR指令)時(shí),P2口送出高8位地址數(shù)據(jù)。P1口:P1是一個(gè)帶有內(nèi)部上拉電阻的8位雙向I/O口,P1的輸出緩沖級(jí)可驅(qū)動(dòng)(吸收或輸出電流)4個(gè)TTL邏輯門(mén)電路。AT89C52的引腳圖如下所示:( AT89C52的引腳圖)AT89C52引腳功能:其測(cè)量電路如下所示:( 濕度測(cè)量電路)濕度傳感器 HS1101是基于獨(dú)特工藝設(shè)計(jì)的電容元件,這些相對(duì)濕度傳感器可以大批量生產(chǎn)。電路圖如下:( 溫度測(cè)量電路)一、DS18B20單片機(jī)的技術(shù)性能描述 1. 獨(dú)特的單線(xiàn)接口方式,DS18B20