【正文】
he current temperature, it will be displayed the realtime data on the LCD1602 at the same time, and constantly scan button, if a button is depressed, it will be produce the corresponding response with the button. Keywords: MCU。 用數(shù)字溫度計(jì) DS18B20 測(cè)量當(dāng)前氣溫, 在 把 實(shí)時(shí)數(shù)據(jù)顯示在 LCD1602 上的同時(shí),不斷掃描按鍵, 如果有按鍵按下,則 對(duì)按鍵做出 相應(yīng)的響應(yīng) 。 主要硬件有: 三端穩(wěn)壓器 LM780AT89S52 單片機(jī)、 字符型液晶顯示模塊 HY1602A、單總線數(shù)字溫度計(jì) DS18B20和 若干按鍵 等 。 本文詳細(xì)介紹了基于 AT89S52 單片機(jī)的數(shù)字 電子 鐘的設(shè)計(jì) ,本電子鐘可以實(shí)現(xiàn)日期、時(shí)間的顯示和調(diào)整,帶有整點(diǎn)提示和一個(gè)鬧鐘,并且可以顯示當(dāng)前氣溫。河南理工大學(xué)畢業(yè)設(shè)計(jì)(論文)說(shuō)明書(shū) i 摘 要 單片機(jī)在 電子產(chǎn)品中的應(yīng)用越來(lái)越廣泛,特別是 51 系列的單片機(jī),由于其使用方便、價(jià)格低廉等優(yōu)勢(shì),在市場(chǎng)上占有很大的份額。 AT89S52 就是 51 系列中的一個(gè)比較成熟的型號(hào),它完全兼容 51 單片機(jī)的指令。 本設(shè)計(jì)包括硬件設(shè)計(jì)和軟件設(shè)計(jì)兩部分 。 軟件大致思路為:使用 12MHz 的晶振,單片機(jī)內(nèi)部的定時(shí)器 0工作在方式 1,每計(jì)數(shù) 50000 個(gè)機(jī)器周期(即 50ms)產(chǎn)生一次中斷,中斷 20次就是一秒,這樣就可以實(shí)現(xiàn)精確計(jì)時(shí)的目的。 關(guān)鍵字:?jiǎn)纹瑱C(jī); 電子鐘; 測(cè)溫; LCD1602; 河南理工大學(xué)畢業(yè)設(shè)計(jì)(論文)說(shuō)明書(shū) ii Abstract MCU in the application of electronic products bees more widely, particularly the 51 series of MCU, because of its ease of use, low prices and other advantages,it’s in a large market share. AT89S52 is a more mature models in the 51series, it is fully patible with the directive MCU 51. This paper describes the MCU based on the AT89S52 the design of digital electronic clock, the electronic clock can be achieved date, time and adjust the show, it also has the exact point timekeeping and a clock,for the better it can display the current temperature. The design includes hardware and software design in two parts. Main hardware: threeterminal regulator LM7805, AT89S52 MCU, character LCD module HY1602A, singlebus digital thermometer DS18B20 and a number of buttons. the general idea for Software: by use of 12 MHz crystal, the MCU39。 electronic clock。 LCD1602; 河南理工大學(xué)畢業(yè)設(shè)計(jì)(論文)說(shuō)明書(shū) iii 目 錄 摘 要 ................................................................................................................... i Abstract ................................................................................................................ii 1 緒論 .................................................................................................................. 1 設(shè)計(jì)要求 ............................................................................................... 1 設(shè)計(jì)思路 ............................................................................................... 1 設(shè)計(jì)重難點(diǎn) ........................................................................................... 2 2 硬件設(shè)計(jì) .......................................................................................................... 3 器件選型 ............................................................................................... 3 硬件總圖 ............................................................................................... 3 器件介紹 ............................................................................................... 4 電源模塊 .................................................................................... 4 單片機(jī) AT89S52 ........................................................................ 5 數(shù)字 式溫度傳感器 DS18B20 ................................................. 12 LCD1602 顯示模塊 .................................................................. 15 3 軟件設(shè)計(jì) ........................................................................................................ 19 軟件設(shè)計(jì)思路 ..................................................................................... 19 實(shí)現(xiàn)功能 .................................................................................. 19 顯示狀態(tài) .................................................................................. 19 定義變量 .................................................................................. 19 接線方式 .................................................................................. 20 編程思路 .................................................................................. 20 主程序流程圖 ..................................................................................... 21 程序清單及注釋 ................................................................................. 22 主程序“電子鐘 .C”................................................................. 23 延時(shí)子程序“ ” ........................................................ 39 河南理工大學(xué)畢業(yè)設(shè)計(jì)(論文)說(shuō)明書(shū) iv 掃描按鍵子程序“ ”........................................ 40 溫度測(cè)量子程序“ ” ............................................. 41 液晶顯示子程序“ ”............................................. 43 4 精度分析 ........................................................................................................ 49 誤差來(lái)源 ............................................................................................. 49 硬件誤差 .................................................................................. 49 軟件誤差 .................................................................................. 49 消除誤差的辦法 ...................................................................... 49 5 總結(jié)與展望 .................................................................................................... 52 致 謝 ............................................................................................................ 53 參考文獻(xiàn) ............................................................................................................ 54 附錄:硬件電路設(shè)計(jì)圖 .................................................................................... 55 河南理工大學(xué)畢業(yè)設(shè)計(jì)(論文)說(shuō)明書(shū) 1 1 緒論 “一寸光陰一寸金,寸金難買寸光陰” ! 時(shí)間對(duì)于我們每一個(gè)人都是非常寶貴的,所以鐘表作為人們掌握時(shí)間的工具就顯得十分重要! 鐘表的出現(xiàn)已經(jīng)有幾百年歷史, 尤其 是擺鐘和后來(lái)的懷表,可以稱作鐘表中的經(jīng)典,不僅大方實(shí)用,而且制作精美。電子時(shí)鐘不僅精確度更高、外觀小巧、功能更加完善,制作成本也是非常低。 設(shè)計(jì)要求 用 AT89S52 單片機(jī),在 1602LCD 上顯示年月日、星期、時(shí)分秒、當(dāng)前溫度。 具備鬧鐘功能,鬧鈴方式為蜂鳴器 持續(xù)響 10 秒鐘,或者用按鍵手動(dòng)關(guān)閉響鈴。 復(fù)位時(shí)間是 2021 年 6 月 10 日 08:59:55。設(shè)計(jì) 以 Atmel 公司的 AT89S52 為核心, 在最小系統(tǒng)的基礎(chǔ)上擴(kuò)展鍵盤(pán),數(shù)字溫度計(jì), 以及 LCD 顯示模塊,硬件設(shè)計(jì)簡(jiǎn)單節(jié)約,其功能的實(shí)現(xiàn)主要靠軟件設(shè)計(jì),所以軟件在本設(shè)計(jì)中是最為重要的。主要硬件有:三端穩(wěn)壓器 LM780AT89S52 單片機(jī)、字符型液晶顯示模塊 HY1602A、單總線數(shù)字溫度計(jì) DS18B20和若干按鍵等。用數(shù)字溫度計(jì) DS18B20 測(cè)量當(dāng)河南理工大學(xué)畢業(yè)設(shè)計(jì)(論文)說(shuō)明書(shū) 2 前氣溫。