【正文】
} send(39。 TR0=1。void restart(){ DQ=1。void write_DS18B20(unsigned char z){ unsigned char i。_nop_()。 delay8zus(40/8)。 for(i=0。}//延時(shí)時(shí)間為8*z+2+1個(gè)us,2為函數(shù)調(diào)用時(shí)間,1為函數(shù)返回時(shí)間void delay8zus(unsigned char z){ for(。b)。P2=p3[j],P0=p[j],delay(2),j++)。void write_DS18B20(unsigned char z)。num。i=0。 loop:if(i) {return 0。 write_DS18B20(0xbe)。if(down==0) {while(!down)。if(sure==0) {while(!sure)。 delay(1)。 P0=0xbf。} if(up==0) {delay(6)。if(cancel==0) {while(!cancel)。 delay(1)。 write_DS18B20(0x55)。 write_DS18B20(0xcc)。 TR0=1。date[i]=0xff,i++)。 date[2]=ca[(TL*625)/100%10]。 TR1=1。 while(!TI)。 send(TH%10+48)。 send(39。設(shè)置并返回產(chǎn)生onm事件的字符數(shù),以字符為單位 = 1 = 0 39。設(shè)置返回接收緩沖區(qū)的大小,以字符為單位 = 2If = True Then = False 39。 send((TL*625)/10%10+48)。)。}includevoid send(unsigned char z){ ES=0。 TH1=0XFD。 date[0]=ca[(TL*625)%10]。 for(i=0。 TL0=0。 write_DS18B20(TL)。 delay(1)。 P2=0Xfd。i=0。TL。 delay(1)。}} P2=0Xfe。}if(TH==56) {TH=125。 th=TH。i8。 delay(1)。} if(sure==0) {delay(5)。 while(i) { if(down==0) {delay(5)。//確定鍵sbit cancel=P1^0。 for(j=0。a) for(b=125。 delay8zus(110/8)。unsigned char read_DS18B20(void){ unsigned char i。 DQ=zamp。_nop_()。}includeincludesbit DQ=P1^2。 }}附錄Ⅲ 子程序includevoid delay8zus(unsigned char)。}void interrupt2() interrupt 2{ TR0=0。539。)。//發(fā)送“警報(bào)” send(39。 deal(T[j].H,T[j].L,zf)。BUZZ=0。T[j].H=T[j].H+temp。 zf=1。i8。 write_DS18B20(0x44)。temperature T[5]。unsigned int count。void RS232_init(void)。//高溫限制sbit PNP=P3^5。這次畢業(yè)設(shè)計(jì)基本的完成了任務(wù)書的要求,實(shí)現(xiàn)了溫度的控制。因此這種系統(tǒng)的設(shè)計(jì)具有比較好的社會效益。使得產(chǎn)品的生產(chǎn)成本降低,從而使系統(tǒng)的使用者獲得的利潤提高了。例如,如果寫一個(gè)簡單的電話撥號程序,則沒有必要對每接收一個(gè)字符都產(chǎn)生事件,因?yàn)槲ㄒ坏却邮盏淖址钦{(diào)制解調(diào)器的“確定”響應(yīng)。所有通訊事件和通訊錯(cuò)誤的列表,參閱 CommEvent 屬性。開機(jī)外部中斷、定時(shí)器、串口初始化發(fā)送溫度轉(zhuǎn)換命令取出溫度值并存儲顯示串口發(fā)送溫度值斷電/加電,報(bào)警串口發(fā)送將第j個(gè)溫度與高低溫限對j5取出高低溫限j5發(fā)送第j個(gè)序列號發(fā)送第j個(gè)序列號YNYN不正常YN顯示20秒后無條件轉(zhuǎn)移圖42 主程序框圖復(fù)位發(fā)送對應(yīng)的序列號讀出高低溫限并存儲發(fā)送對應(yīng)的序列號退出中斷進(jìn)入中斷選擇一個(gè)DS18B20將高低溫限寫入對應(yīng)的DS18B20設(shè)置高溫限制設(shè)置低溫限制圖43 設(shè)置高低溫限程序框圖主程序請參見附錄II,子程序請參見附錄Ⅲ。⑥ 數(shù)字量的轉(zhuǎn)換精度及轉(zhuǎn)換時(shí)間可通過簡單的編程來控制:9位精度的轉(zhuǎn)換時(shí)間為93.75 ms::12位精度的轉(zhuǎn)換時(shí)間750ms。在IC溫度傳感器中選擇平時(shí)接觸較多的DS18B20。但如果要以數(shù)字方式來讀取熱敏溫度傳感器的溫度值,就要安裝有模數(shù)轉(zhuǎn)換模塊。 題目分析本設(shè)計(jì)是一個(gè)數(shù)字多點(diǎn)溫度監(jiān)控系統(tǒng),能夠?qū)崿F(xiàn)多點(diǎn)溫度測量,能在超限的情況下進(jìn)行控制、調(diào)整,并報(bào)警,并可以將溫度數(shù)據(jù)通過串口發(fā)送給上位機(jī)。片上Flash允許程序存儲器在系統(tǒng)可編程,亦適于常規(guī)編程器。本設(shè)計(jì)是一個(gè)數(shù)字溫度測量及監(jiān)控系統(tǒng),能夠進(jìn)行大范圍的溫度測量,并能在超限的情況下進(jìn)行控制、調(diào)整,并報(bào)警。它的主要組成部分有: AT89S52單片機(jī)、鍵盤及顯示電路、溫度測量電路、串口通信電路等組成。基于以上幾點(diǎn),本次畢業(yè)設(shè)計(jì)選擇IC溫度傳感器?!痉桨傅谋容^與評價(jià)】溫度傳感器有:傳統(tǒng)熱敏溫度傳感器和IC溫度傳感器。完成多點(diǎn)溫度測量與監(jiān)控的軟硬件設(shè)計(jì)。完成程序設(shè)計(jì)及實(shí)物調(diào)試。【前言】隨著信息技術(shù)革命的深入和計(jì)算機(jī)技術(shù)的飛速發(fā)展,單片機(jī)的應(yīng)用越來越廣泛,并逐漸發(fā)展成為一門關(guān)鍵的技術(shù)學(xué)科。另外,隨著工藝水平不斷提高,IC溫度傳感器的價(jià)格也不斷下降,其價(jià)格也逐漸可以和熱敏溫度傳感器相媲美。先電腦上做好仿真之后,然后對其進(jìn)行實(shí)物調(diào)試,能實(shí)現(xiàn)系統(tǒng)各性能指標(biāo)均符合要求。[關(guān)鍵詞]單片機(jī) 單總線數(shù)字溫度傳感器 串口發(fā)送 上位機(jī)AT89S52 Microcontroller based multipoint temperature measurement and monitoringLiu Xinglong0802 application of electronicAbstract:With more and more intelligent electronic products, using SCM to temperature monitoring has bee mainstream. This article describes the digital temperature measurement and control system design. In this paper, single chip to achieve the temperature control. Its main ponents are: AT89S52 microcontroller, keyboard and display circuit, the temperature measurement circuit, serial munication circuit. It can be realtime display and set temperature, to achieve automatic control of temperature. Test shows that the design of temperature control are easy, simple features, which significantly increased the temperature was charged with technical indicators.Key words: SCM Singlebus digital temperature senso