【正文】
NOP 。NOP一定要有 SETB E JB ,BUSY 。 RET DS18B20的時(shí)序 由于DS18B20采用的是1-Wire總線協(xié)議方式,即在一根數(shù)據(jù)線實(shí)現(xiàn)數(shù)據(jù)的雙向傳輸,而對(duì)AT89S51單片機(jī)來(lái)說,硬件上并不支持單總線協(xié)議,因此,我們必須采用軟件的方法來(lái)模擬單總線的協(xié)議時(shí)序來(lái)完成對(duì)DS18B20芯片的訪問。 由于DS18B20是在一根I/O線上讀寫數(shù)據(jù),因此,對(duì)讀寫的數(shù)據(jù)位有著嚴(yán)格的時(shí)序要求。DS18B20有嚴(yán)格的通信協(xié)議來(lái)保證各位數(shù)據(jù)傳輸?shù)恼_性和完整性。該協(xié)議定義了幾種信號(hào)的時(shí)序:初始化時(shí)序、讀時(shí)序、寫時(shí)序。所有時(shí)序都是將主機(jī)作為主設(shè)備,單總線器件作為從設(shè)備。而每一次命令和數(shù)據(jù)的傳輸都是從主機(jī)主動(dòng)啟動(dòng)寫時(shí)序開始,如果要求單總線器件回送數(shù)據(jù),在進(jìn)行寫命令后,主機(jī)需啟動(dòng)讀時(shí)序完成數(shù)據(jù)接收。數(shù)據(jù)和命令的傳輸都是低位在先。 (1)DS18B20的復(fù)位時(shí)序 圖54 DS18B20復(fù)位時(shí)序圖(2)DS18B20的讀時(shí)序 對(duì)于DS18B20的讀時(shí)序分為讀0時(shí)序和讀1時(shí)序兩個(gè)過程。對(duì)于DS18B20的讀時(shí)隙是從主機(jī)把單總線拉低之后,在15秒之內(nèi)就得釋放單總線,以讓DS18B20把數(shù)據(jù)傳輸?shù)絾慰偩€上。DS18B20在完成一個(gè)讀時(shí)序過程,至少需要60us才能完成。 圖55 DS18B20讀時(shí)序圖(3)DS18B20的寫時(shí)序 對(duì)于DS18B20的寫時(shí)序仍然分為寫0時(shí)序和寫1時(shí)序兩個(gè)過程。對(duì)于DS18B20寫0時(shí)序和寫1時(shí)序的要求不同,當(dāng)要寫0時(shí)序時(shí),單總線要被拉低至少60us,保證DS18B20能夠在15us到45us之間能夠正確地采樣IO總線上的“0”電平,當(dāng)要寫1時(shí)序時(shí),單總線被拉低之后,在15us之內(nèi)就得釋放單總線。圖56 DS18B20的寫時(shí)序程序運(yùn)行正常,各功能達(dá)到要求。圖57 程序運(yùn)行圖58 鬧鈴調(diào)節(jié)圖59時(shí)間調(diào)節(jié)圖510 溫度感應(yīng)致謝 經(jīng)過幾個(gè)月的努力,終于將本論文編寫完畢,這也意味著我的大學(xué)生活即將結(jié)束,我就將熱情投入到以后的工作中,希望我的未來(lái)旅途也能像本次畢業(yè)設(shè)計(jì)一樣順利。在此,特別感謝在本次畢業(yè)設(shè)計(jì)中幫助我的老師、同學(xué)及網(wǎng)友。 首先,感謝蘭明老師在本次設(shè)計(jì)之初為我收集的大量資料,使我受益良多,在設(shè)計(jì)過程中給予我莫大幫助,為本次設(shè)計(jì)能順利完成打下了夯實(shí)的基礎(chǔ),感謝您對(duì)我的大力支持與幫助。其次,感謝網(wǎng)友為我提供解決DS18B20溫度感應(yīng)器讀寫子程序編程問題的方法。沒有你們的幫助,本次畢業(yè)設(shè)計(jì)不會(huì)如此順利完成。 在即將離別之際,我衷心感謝我的母校,感謝給予我知識(shí)的老師們。這里見證了我成長(zhǎng)的每一步,這里有我大學(xué)時(shí)代的許多美好回憶。祝愿母校的未來(lái)更輝煌。參考文獻(xiàn)[1].張毅坤,陳善久,裘雪紅.單片微型計(jì)算機(jī)原理及應(yīng)用[M].西安:電子科技大學(xué)出版社,1998.[2].[M].北京:北京理工大學(xué)出版社1997.[3].陳汝全,林水生,[M].西安:電子科技大學(xué)出版社,1995.[4].[M].北京:科學(xué)出版社,2009.[5].張謹(jǐn),張偉, 99SE入門與提高[M].北京:人民郵電出版社,2007.[6].[DB/OL].?from=relatedamp。hasrec=1,20100810[7].[DB/OL]. ,20100515[8].[DB/OL].?from=relatedamp。hasrec=1,20120313[9].[M].北京:北京航空航天大學(xué)出版社,1995.[10].候伯亨,[M].西安:西安電子科技大學(xué)出版社,1996.[11].[M].北京:清華大學(xué)出版社,1993.[12].?學(xué)習(xí)指導(dǎo)?題解?[M]:華中科技大學(xué)出版社,2004.[13].劉永華,[M].北京:中國(guó)鐵道出版社,2006.[14].[M].西安:西北工業(yè)大學(xué)出版社,1999.[15].[M].北京:高等教育出版社,2002.[16].[M].長(zhǎng)沙:國(guó)防科技大學(xué)出版社,2001.[17].[M].北京:機(jī)械工業(yè)出版社,2005.[18].劉永華,[M].北京:中國(guó)鐵道出版社,2006.附錄AThe Design and facture of a Digital temperature controller Based on 78F9234 Single ChipMinli Tang , Hengyu Wuy(Corresponding author),Baoru HanDepartment of Electronic Engineering,Hainan Software Profession Institute Qionghai, Hainan ,571400 ,Chinagslstml@ , whytml@,6183191@Abstract The system is a nucleus model on the main control of single chip puter 78F9234, using DS18B20 temperature sensor to collect temperature data and digital tube monitor to show temperature data, with up and down limitation of temperature control key to change temperature rise and drop, heating indicator equipment, overheating protection and buzzer warning function, singlechip microputer’s burning port and antideath circuit. The system is convenient to use, cost is paratively low and control system in software can be further improved to expand its function without adding its hardware cost,which would enhance the cost performance of temperature controllers. Key words: Singlechip microputer 78F9234, AutoControl Technology, Digital Temperature ControllerI. IntroductionTemperature is one of the most basic detecting parameters in industrial automation, domestic appliance, environmental protection, safe production, auto industry and so on. Therefore temperature detecting is very important. With science technology developing, enterprises raise a higher demand for it, hoping to use new detecting methods to produce a new generation temperature detecting system, which is adaptable, with higher accuracy, more stabilization and intelligent new generation temperature detecting system. Thesis integrates singlechip digital control technology into the design of digital temperature control and designs a new type of digitalizing temperature control system. II. Overall design of the programMicrocontroller digital temperature control device for the control system is based on the core 78F9234 MCU. The entire system hardware ponents, including key input circuit, MCU control, heating instructions circuit, overheating protection circuit, temperature sensing circuit, a digital display circuit, control and antideath circuit, warning circuit, such as burning port parts. Microcontroller Design diagram Digital temperature control device was shown in Figure 1. The system can be through keyboard input, you can preset the need to control the temperature. Then, the system automatically pleted the same time, the system display module can realtime display the current temperature of the 78F9234 MCU is the core ponent of the entire temperature control system. Temperature sensor is placed in the heating system. The temperature signals can convert through 78F9234 MCU, Its A / Dconverter circuit carry out analogdigital conversion. The quality of controlling and level of automation can be greatly improved by the software and hardware system. LED module displays the current temperature value and the related other information. According to the system39。s current temperature, CPU sets temperature in order to do the macrocontrol on temperature implementing parts. Temperature implementing parts execute detection mainly through the temperature sensor, heating and cooling by relay and heating power’s on and off through the overheating temperaturesensitive switch. This will enable the control of sensitive, reliable, interference etc.III. Hardware System DesignA. The control module part 78F9234 chip is 8bit singlechip microcontroller, with its flash memory 2K/4Kbyte. It set instruction execution time, the time scope is highspeed () ~ lowspeed () (Typical value for 8MHz). It has 8 bits 8 registers, builtin A / D converter, watchdog timer, and so on. Its features are highly integrated, simple structure, small size, high reliability, strong processing power and speed fast. And it is patible with C languag