外文文獻(xiàn)翻譯-單片機(jī)外文文獻(xiàn)翻譯--基于單片機(jī)的多點(diǎn)溫度檢測(cè)系統(tǒng)的設(shè)計(jì)【中文3330字】 【中英文WORD】
外文文獻(xiàn)翻譯-單片機(jī)外文文獻(xiàn)翻譯--基于單片機(jī)的多點(diǎn)溫度檢測(cè)系統(tǒng)的設(shè)計(jì)【中文3330字】 【中英文WORD】,中文3330字,中英文WORD,外文文獻(xiàn)翻譯-單片機(jī)外文文獻(xiàn)翻譯,基于單片機(jī)的多點(diǎn)溫度檢測(cè)系統(tǒng)的設(shè)計(jì)【中文3330字】,【中英文WORD】,外文,文獻(xiàn),翻譯,單片機(jī),基于,多點(diǎn),溫度,檢測(cè),系統(tǒng),設(shè)計(jì)
中文譯文:
基于單片機(jī)的多點(diǎn)溫度檢測(cè)系統(tǒng)的設(shè)計(jì)
格林頓
摘要:基于單片機(jī)的多通道數(shù)據(jù)采集系統(tǒng)是由將來自傳感器的信號(hào)通過放大、線性化、濾波、同步采樣保持等處理后,輸入A/D轉(zhuǎn)換為數(shù)字信號(hào)后由單片機(jī)采集,然后利用單片機(jī)與PC機(jī)的通信將數(shù)據(jù)送到PC機(jī)進(jìn)行數(shù)據(jù)的存儲(chǔ)、后期處理與顯示,實(shí)現(xiàn)了數(shù)據(jù)處理功能強(qiáng)大、顯示直觀、界面友好、性價(jià)比高、應(yīng)用廣泛的特點(diǎn),可廣泛應(yīng)用于工業(yè)控制、儀器、儀表、機(jī)電一體化、智能家居等諸多領(lǐng)域。
關(guān)鍵字:多通道 數(shù)據(jù)采集 單片機(jī)
1引言
隨著社會(huì)的發(fā)展和技術(shù)的進(jìn)步,人們?cè)絹碓阶⒅販囟葯z測(cè)與顯示的重要性。溫度檢測(cè)與狀態(tài)顯示技術(shù)與設(shè)備已經(jīng)普遍應(yīng)用于各行各業(yè),市場(chǎng)上的產(chǎn)品層出不窮。溫度檢測(cè)及顯示也逐漸采用自動(dòng)化控制技術(shù)來實(shí)現(xiàn)監(jiān)控。本課題就是一個(gè)溫度檢測(cè)及狀態(tài)顯示的監(jiān)控系統(tǒng)。
2系統(tǒng)方案
本系統(tǒng)采用 AT89C51 作為該系統(tǒng)的單片機(jī)。系統(tǒng)整體硬件電路包括,電源電路,傳感器電路,溫度顯示電路,上下限報(bào)警電路等。報(bào)警電路可以在被測(cè)溫度不在上下限范圍內(nèi)時(shí),發(fā)出報(bào)警鳴叫聲音。溫度控制的基本原理為:當(dāng)DSl8B20 采集到溫度信號(hào)后,將溫度信號(hào)送至AT89C51 中處理,同時(shí)將溫度送到LCD 液晶屏顯示,單片機(jī)根據(jù)初始化設(shè)置的溫度上下限進(jìn)行判斷處理,即如果溫度大于所設(shè)的最高溫度就啟動(dòng)風(fēng)扇降溫;如果溫度小于所設(shè)定的最低溫度就啟動(dòng)報(bào)警裝置。溫度控制器的原理圖。
3系統(tǒng)硬件設(shè)計(jì)
3.1單片機(jī)AT89C51 的介紹
AT89C51是美國ATMEL公司生產(chǎn)的低電壓,高性能COMS8位單片機(jī),片內(nèi)含4Kbytes的可反復(fù)擦寫的只讀程序存儲(chǔ)器(PEROM)和128bytes的隨機(jī)存取數(shù)據(jù)存儲(chǔ)器(RAM),器件采用ATMEL公司的高密度、非易失性存儲(chǔ)技術(shù)生產(chǎn),兼容標(biāo)準(zhǔn)MCS-51指令系統(tǒng),片內(nèi)置通用8位中央處理器(CPU)和Flash存儲(chǔ)單元,功能強(qiáng)大AT89C51單片機(jī)可為您提供許多高性價(jià)比的應(yīng)用場(chǎng)合,可靈活應(yīng)用于各種控制領(lǐng)域。
主要性能參數(shù):
·與MCS-51產(chǎn)品指令系統(tǒng)完全兼容;
·4K字節(jié)可重擦寫Flash閃速存儲(chǔ)器;
·1000次擦寫周期;
·全靜態(tài)操作:0Hz—24MHz;
·三級(jí)加密程序存儲(chǔ)器;
·128×8字節(jié)內(nèi)部RAM;
·32個(gè)可編程I/O口線;
·2個(gè)16位定時(shí)/計(jì)數(shù)器;
·6個(gè)中斷源;
·可編程串行UART通道;
·低功耗空閑和掉電模式。
功能特性概述:
AT89C51提供以下標(biāo)準(zhǔn)功能:4K字節(jié)Flash閃速存儲(chǔ)器,128字節(jié)內(nèi)部RAM,32個(gè)I/O口線,兩個(gè)16位定時(shí)/計(jì)數(shù)器,一個(gè)5向量?jī)杉?jí)中斷結(jié)構(gòu),一個(gè)全雙工串行通信口,片內(nèi)振蕩器及時(shí)鐘電路。同時(shí),AT89C51可降至0Hz的靜態(tài)邏輯操作,并支持兩種軟件可選的節(jié)電工作模式??臻e方式停止CPU的工作,但允許RAM,定時(shí)/計(jì)數(shù)器。串行通信口及中斷系統(tǒng)繼續(xù)工作。掉電方式保存RAM中的內(nèi)容,但振蕩器停止工作并禁止其它所有部件工作直到下一個(gè)硬件復(fù)位。
引腳功能說明:
·VCC:電源電壓;
·GND:地;
·P0口:P0口是一組8位漏極開路型雙向I/O口,也即地址/數(shù)據(jù)總線復(fù)用口。作為輸出口用時(shí),每位能吸收電流的方式驅(qū)動(dòng)8個(gè)TTL邏輯門電路,對(duì)端口寫“1”可作為高阻抗輸入端用。
在訪問外部數(shù)據(jù)存儲(chǔ)器或程序存儲(chǔ)器時(shí),這組口線分時(shí)轉(zhuǎn)換地址(低8位)和數(shù)據(jù)總線復(fù)用,在訪問期間即或內(nèi)部上拉電阻。
在Flash編程時(shí),P0口接收指令字節(jié),而在程序校驗(yàn)時(shí),輸出指令字節(jié),校驗(yàn)時(shí),要求外接上拉電阻。
·P1口:P1是一個(gè)帶有內(nèi)部上拉電阻的8位雙向I/O口,P1的輸出緩沖級(jí)可驅(qū)動(dòng)(吸收或輸出電流)4個(gè)TTL邏輯門電路。對(duì)端口寫“1”,通過內(nèi)部的上拉電阻把端口拉到高電平,此時(shí)可作輸入口。作輸入口使用時(shí),因?yàn)閮?nèi)部存在上拉電阻,某個(gè)引腳被外部信號(hào)拉低時(shí)會(huì)輸出一個(gè)電流(IIL)。
Flash編程和程序校驗(yàn)期間,P1接收低8位地址。
·P2口:P2是一個(gè)帶有內(nèi)部上拉電阻的8位雙向I/O口,P2的輸出緩沖級(jí)可驅(qū)動(dòng)(吸收或輸出電流)4個(gè)TTL邏輯門電路。對(duì)端口寫“1”,通過內(nèi)部的上拉電阻把端口拉到高電平,此時(shí)可作輸入口。作輸入口使用時(shí),因?yàn)閮?nèi)部存在上拉電阻,某個(gè)引腳被外部信號(hào)拉低時(shí)會(huì)輸出一個(gè)電流(IIL)。
在訪問外部程序存儲(chǔ)器或16位地址的外部數(shù)據(jù)存儲(chǔ)器(例如執(zhí)行MOVX@DPTR指令)時(shí),P2口送出高8位地址數(shù)據(jù)。在訪問8位地址的外部數(shù)據(jù)存儲(chǔ)器(如執(zhí)行MOVX@RI指令)時(shí),P2口線上的內(nèi)容在整個(gè)訪問期間不改變。
Flash編程或檢驗(yàn)時(shí),P2亦接收高位地址和其它控制信號(hào)。
·P3口:P3口是一組帶有內(nèi)部上拉電阻的8位雙向I/O口。P3口輸出緩沖級(jí)可驅(qū)動(dòng)(吸收或輸出電流)4個(gè)TTL邏輯門電路。對(duì)P3口寫入“1”時(shí),它們被內(nèi)部上拉電阻拉高并可作為輸入端口。作輸入端時(shí),被外部拉低的P3口將用上拉電阻輸出電流(IIL)。
P3口還接收一些用于Flash閃速存儲(chǔ)器編程和程序校驗(yàn)的控制信號(hào)。
·RET:復(fù)位輸入。當(dāng)振蕩器工作時(shí),RET引腳出現(xiàn)兩個(gè)機(jī)器周期以上高電平將使單片機(jī)復(fù)位。
·ALE/:當(dāng)訪問外部程序存儲(chǔ)器或數(shù)據(jù)存儲(chǔ)器時(shí),ALE(地址鎖存允許)輸出脈沖用于鎖存地址的低8位字節(jié)。對(duì)Flash存儲(chǔ)器編程期間,該引腳還用于輸入編程脈沖()。即使不訪問外部存儲(chǔ)器,ALE仍以時(shí)鐘振蕩頻率的1/6輸出固定的正脈沖信號(hào),因此它可對(duì)外輸出時(shí)鐘或用于定時(shí)目的。要注意的是:每當(dāng)訪問外部數(shù)據(jù)存儲(chǔ)器時(shí)將跳過一個(gè)ALE脈沖。
如有必要,可通過對(duì)特殊功能寄存器(SFR)區(qū)中的8EH單元的D0位置位,可禁止ALE操作。該位置位后,只有一條MOVX和MOVC指令A(yù)LE才會(huì)被激活。此外,該引腳會(huì)被微弱拉高,單片機(jī)執(zhí)行外部程序時(shí),應(yīng)設(shè)置ALE無效。
·:程序儲(chǔ)存允許()輸出是外部程序存儲(chǔ)器的讀選通信號(hào),當(dāng)AT89C51由外部程序存儲(chǔ)器取指令(或數(shù)據(jù))時(shí),每個(gè)機(jī)器周期兩次有效,即輸出兩個(gè)脈沖。在此期間,當(dāng)訪問外部數(shù)據(jù)存儲(chǔ)器,這兩次有效的信號(hào)不出現(xiàn)。
EA/VPP:外部訪問允許。欲使CPU僅訪問外部程序存儲(chǔ)器(地址為0000H—FFFFH),EA端必須保持低電平(接地)。需注意的是:如果加密位LB1被編程,復(fù)位時(shí)內(nèi)部會(huì)鎖存EA端狀態(tài)。如EA端為高電平(接VCC端),CPU則執(zhí)行內(nèi)部程序存儲(chǔ)器中的指令。
Flash存儲(chǔ)器編程時(shí),該引腳加上+12V的編程允許電源VPP,當(dāng)然這必須是該器件是使用12V編程電壓VPP。
XTAL1:振蕩器反相放大器及內(nèi)部時(shí)鐘發(fā)生器的輸入端。
XTAL2:振蕩器反相放大器的輸出端。
Ready/:字節(jié)編程的進(jìn)度可通過RDY/輸出信號(hào)監(jiān)測(cè),編程期間,ALE變?yōu)楦唠娖健癏”后P3.4(RDY/)端電平被拉低,表示正在編程狀態(tài)(忙狀態(tài))。編程完成后,P3.4變?yōu)楦唠娖奖硎緶?zhǔn)備就緒狀態(tài)。
時(shí)鐘振蕩器:
AT89C51中有一個(gè)用于構(gòu)成內(nèi)部振蕩器的高增益反相放大器,引腳XTAL1和XTAL2分別是該放大器的輸入端和輸出端。這個(gè)放大器與作為反饋元件的片外石英晶體 或陶瓷諧振器一起構(gòu)成自激振蕩器。
用戶也可以采用外部時(shí)鐘。這種情況下,外部時(shí)鐘脈沖接到XTAL1端,即內(nèi)部時(shí)鐘發(fā)生器的輸入端,XTAL2則懸空。
由于外部時(shí)鐘信號(hào)是通過一個(gè)2分頻觸發(fā)器后作為內(nèi)部時(shí)鐘信號(hào)的,所以對(duì)外部時(shí)鐘信號(hào)的占空比沒有特殊要求,但最小高電平持續(xù)時(shí)間和最大的低電平持續(xù)時(shí)間應(yīng)符合產(chǎn)品技術(shù)條件的要求。
空閑節(jié)電模式:
在空閑工作模式狀態(tài),CPU保持睡眠狀態(tài)而所有片內(nèi)的外設(shè)仍保持激活狀態(tài),這種方式由軟件產(chǎn)生。此時(shí),片內(nèi)RAM和所有特殊功能寄存器的內(nèi)容保持不變。空閑模式可由任何允許的中斷請(qǐng)求或硬件復(fù)位終止。
通過硬件復(fù)位也可將空閑工作模式終止。需要注意的是:當(dāng)由硬件復(fù)位來終止空閑工作模式時(shí),CPU通常是從激活空閑模式那條指令的下一條指令開始繼續(xù)執(zhí)行程序的,要完成內(nèi)部復(fù)位操作,硬件復(fù)位脈沖要保持兩個(gè)機(jī)器周期有效,在這種情況下,內(nèi)部禁止CPU訪問片內(nèi)RAM,而允許訪問其它端口。為了避免可能對(duì)端口產(chǎn)生意外寫入,激活空閑模式的那條指令后一條指令不應(yīng)是一條對(duì)端口或外部存儲(chǔ)器的寫入指令。
掉電模式:
在掉電模式下,振蕩器停止工作,進(jìn)入掉電模式的指令是最后一條被執(zhí)行的指令,片內(nèi)RAM和特殊功能寄存器的內(nèi)容在終止掉電模式前被凍結(jié)。退出掉電模式的唯一方法是硬件復(fù)位,復(fù)位后將重新定義全部特殊功能寄存器但不改變RAM中的內(nèi)容,在VCC恢復(fù)到正常工作電平前,復(fù)位應(yīng)無效,且必須保持一定時(shí)間以使振蕩器重啟動(dòng)并穩(wěn)定工作。
程序存儲(chǔ)器的加密:
當(dāng)加密位LB1被編程時(shí),在復(fù)位期間,EA端的邏輯電平被采樣并鎖存,如果單片機(jī)上電后一直沒有復(fù)位,則鎖存起的初始值是一個(gè)隨機(jī)數(shù),且這個(gè)隨機(jī)數(shù)會(huì)一直保存到真正復(fù)位為止。為使單片機(jī)能正常工作,被鎖存的EA電平值必須與該引腳當(dāng)前的邏輯電平一致。此外,加密位只能通過整片擦除的方法清除。
Flash閃速存儲(chǔ)器的編程:
AT89C51單片機(jī)內(nèi)部有4K字節(jié)的Flash PEROM,這個(gè)Flash存儲(chǔ)陣列出廠時(shí)已處于擦除狀態(tài)(即所有存儲(chǔ)單元的內(nèi)容均為FFH),用戶隨時(shí)可對(duì)其進(jìn)行編程。編程接口可接收高電壓(+12V)或低電壓(VCC)的允許編程信號(hào)。低電壓編程模式適合于用戶在線編程系統(tǒng),而高電壓編程模式可與通用EPROM編程器兼容。
AT89C51的程序存儲(chǔ)器陣列是采用字節(jié)寫入方式編程的,每次寫入一個(gè)字節(jié),要對(duì)整個(gè)芯片內(nèi)的PEROM程序存儲(chǔ)器寫入一個(gè)非空字節(jié),必須使用片擦除的方式將整個(gè)存儲(chǔ)器的內(nèi)容清除。
編程方法:
編程前,須根據(jù)表設(shè)置好地址、數(shù)據(jù)及控制信號(hào)。AT89C51編程方法如下:
1、在地址線上加上要編程單元的地址信號(hào)。
2、在數(shù)據(jù)線上加上要寫入的數(shù)據(jù)字節(jié)。
3、激活相應(yīng)的控制信號(hào)。
4、在高電壓編程方式時(shí),將EA/VPP端加上+12V編程電壓。
5、每對(duì)Flash存儲(chǔ)陣列寫入一個(gè)字節(jié)或每寫入一個(gè)程序加密位,加上一個(gè)ALE/編程脈沖。改變編程單元的地址和寫入的數(shù)據(jù),重復(fù)1—5步驟,直到全部文件編程結(jié)束。每個(gè)字節(jié)寫入周期是自身定時(shí)的,通常約為1.5ms。
數(shù)據(jù)查詢:
AT89C51單片機(jī)用數(shù)據(jù)查詢方式來檢測(cè)一個(gè)寫周期是否結(jié)束,在一個(gè)寫周期中,如需讀取最后寫入的那個(gè)字節(jié),則讀出的數(shù)據(jù)最高位是原來寫入字節(jié)最高位的反碼。寫周期完成后,有效的數(shù)據(jù)就會(huì)出現(xiàn)在所有輸出端上,此時(shí),可進(jìn)入下一個(gè)字節(jié)的寫周期,寫周期開始后,可在任意時(shí)刻進(jìn)行數(shù)據(jù)查詢。
程序校驗(yàn):
如果加密位LB1、LB2沒有進(jìn)行編程,則代碼數(shù)據(jù)可通過地址和數(shù)據(jù)線讀回原編寫的數(shù)據(jù)。加密位不可直接校驗(yàn),加密位的校驗(yàn)可通過對(duì)存儲(chǔ)器的校驗(yàn)和寫入狀態(tài)來驗(yàn)證。
芯片擦除:
利用控制信號(hào)的正確組合并保持ALE/引腳10ms的低電平脈沖寬度即可將PEROM陣列(4K字節(jié))和三個(gè)加密位整片擦除,代碼陳列在片擦除操作中將任何非空單元寫入“1”,這步驟需再編程之前進(jìn)行。
讀片內(nèi)簽名字節(jié):
讀簽名字節(jié)的過程和單元030H、031H及032H的正常校驗(yàn)相仿,只需將P3.6和P3.7保持低電平,返回值意義如下:
(030H)=1EH聲明產(chǎn)品由ATMEL公司制造
(031H)=51H聲明為AT89C51單片機(jī)
(032H)=FFH聲明為12V編程電壓
(032H)=05H聲明為5V編程電壓
編程接口:
采用控制信號(hào)的正確組合可對(duì)Flash閃速存儲(chǔ)陣列中的每一代碼字節(jié)進(jìn)行寫入和存儲(chǔ)器的整片擦除,寫操作周期是自身定時(shí)的,初始化后它將自動(dòng)定時(shí)到操作完成。
3.2 DS18B20傳感器的介紹
在傳統(tǒng)的模擬信號(hào)遠(yuǎn)距離溫度測(cè)量系統(tǒng)中,需要很好的解決引線誤差補(bǔ)償問題、多點(diǎn)測(cè)量切換誤差問題和放大電路零點(diǎn)漂移誤差問題等技術(shù)問題,才能夠達(dá)到較高的測(cè)量精度。另外一般監(jiān)控現(xiàn)場(chǎng)的電磁環(huán)境都非常惡劣,各種干擾信號(hào)較強(qiáng),模擬溫度信號(hào)容易受到干擾而產(chǎn)生測(cè)量誤差,影響測(cè)量精度[5]。因此,在溫度測(cè)量系統(tǒng)中,采用抗干擾能力強(qiáng)的新型數(shù)字溫度傳感器是解決這些問題的最有效方案, 與其它溫度傳感器相比DSl820 具有以下特點(diǎn):
(1)獨(dú)特的單線接口方式。DSl820 在與微處理器連接時(shí)僅需要一條接口線即可實(shí)現(xiàn)微處理器與DSl820 的雙向通訊。(2)多點(diǎn)功能簡(jiǎn)化了分布式溫度檢測(cè)的應(yīng)用。(3)DSl820 在使用中無需任何外圍元件。(4)可用數(shù)據(jù)線供電,電壓范圍從3.0V 到5.5V。(5)可測(cè)量的溫度范圍從-55℃到+125℃,增量值0. 5℃;華氏溫度范圍從-67 到+257,增量值0.9。(6)支持多點(diǎn)組網(wǎng)功能。多個(gè)DS1820 可以并接在同一條總線上,實(shí)現(xiàn)多點(diǎn)測(cè)溫。(7)9 位的溫度分辨率。測(cè)量結(jié)果以9 位數(shù)字量方式串行傳送。(8)用戶可設(shè)定溫度報(bào)警門限值。(9)有超溫度搜尋功能。
(1) DSl8B20 的工作原理
DS18B20 的內(nèi)部結(jié)構(gòu)DSl8B20 的測(cè)溫原理框圖如圖3.2 所示。圖中低溫度系數(shù)品振的振蕩頻率受溫度影響很小,用于產(chǎn)生同定頻率的脈沖信號(hào)送給計(jì)數(shù)器l。高溫度系數(shù)晶振隨溫度變化其振蕩頻率明顯改變。所產(chǎn)生的信號(hào)作為計(jì)數(shù)器2 的脈沖輸入。計(jì)數(shù)器1、計(jì)數(shù)器2和溫度寄存器被預(yù)置在-55℃所對(duì)應(yīng)的一個(gè)基數(shù)值。計(jì)數(shù)器l 對(duì)低溫度系數(shù)晶振產(chǎn)生的脈沖信號(hào)進(jìn)行減法計(jì)數(shù),當(dāng)計(jì)數(shù)器1 的預(yù)置值減到O 時(shí),溫度計(jì)數(shù)器的值將加l,計(jì)數(shù)器l 的預(yù)置值將被重新裝人,計(jì)數(shù)器l 重新開始對(duì)低溫度系數(shù)晶振產(chǎn)生的脈沖信號(hào)進(jìn)行計(jì)數(shù),如此循環(huán)直到計(jì)數(shù)器2 計(jì)數(shù)到O 時(shí),停止溫度寄存器的累加,此時(shí)溫度寄存器中的數(shù)值即為所測(cè)溫度。圖3.2 中的斜率累加器用于補(bǔ)償和修正測(cè)溫過程中的非線性,其輸出小于修正計(jì)數(shù)器l 的預(yù)置值。
(2)DS18B20 與AT89C51 的接口方式
DS18B20 與單片機(jī)的連接方式有兩種:即寄生電源方式和外部電源方式。
寄生電源方式:在寄生電源供電方式下,DS18B20 從單線信號(hào)線上汲取能量:在信號(hào)線DQ 處于高電平期間把能量?jī)?chǔ)存在內(nèi)部電容里,在信號(hào)線處于低電平期間消耗電容上的電能工作,直到高電平到來再給寄生電源(電容)充電。寄生電源方式有三個(gè)好處: 1)進(jìn)行遠(yuǎn)距離測(cè)溫時(shí),無需本地電源。 2)可以在沒有常規(guī)電源的條件下讀取ROM。 3)電路更加簡(jiǎn)潔,僅用一根I/O 口實(shí)現(xiàn)測(cè)溫。要想使DS18B20 進(jìn)行精確的溫度轉(zhuǎn)換,I/O 線必須保證在溫度轉(zhuǎn)換期間提供足夠的能量,由于每個(gè)DS18B20 在溫度轉(zhuǎn)換期間工作電流達(dá)到1mA,當(dāng)幾個(gè)溫度傳感器掛在同一根I/O 線上進(jìn)行多點(diǎn)測(cè)溫時(shí),只靠4.7K 上拉電阻就無法提供足夠的能量,會(huì)造成無法轉(zhuǎn)換溫度或溫度誤差極大。
外部電源供電方式:在外部電源供電方式下,DS18B20 工作電源由VDD 引腳接入,此時(shí)I/O 線不需要強(qiáng)上拉,不存在電源電流不足的問題,可以保證轉(zhuǎn)換精度,同時(shí)在總線上理論可以掛接任意多個(gè)DS18B20 傳感器,組成多點(diǎn)測(cè)溫系統(tǒng)。
本系統(tǒng)采用外部電源方式。連接方法即DS18B20 的1 腳接地,2 腳(DQ 引腳)與AT89C51 的一根I/O 口線相連,3 腳接+5V。在A89S52 的I/O 口線與+5V 之間連接一4.7K 的上拉電阻,以保證數(shù)據(jù)采集的正常進(jìn)行。若要組成多點(diǎn)溫度檢測(cè)系統(tǒng),可在單片機(jī)的同一根I/O 口線上,以相同的連接方法并聯(lián)多片DS18B20 芯片。
3.3 LCD1602液晶屏
1602 液晶顯示模塊可以和單片機(jī)AT89C51 直接接口。
3.4蜂鳴器驅(qū)動(dòng)電路
由于蜂鳴器的工作電流一般比較大,以致于單片機(jī)的I/O 口是無法直接驅(qū)動(dòng)的,所以要利用放大電路來驅(qū)動(dòng),一般使用三極管來放大電流就可以了。當(dāng)所測(cè)的溫度低于6 攝氏度時(shí),報(bào)警。
3.5風(fēng)扇電路
當(dāng)所測(cè)的溫度高于80 攝氏度時(shí),啟動(dòng)風(fēng)扇電路。因?yàn)楣ぷ麟娏鞅容^大,所以用放大電路來驅(qū)動(dòng),即用三極管來放大電流就可以了。當(dāng)溫度高于80℃時(shí),給單片機(jī)一個(gè)命令,單片機(jī)P2.6 引腳輸出高電平,三極管導(dǎo)通,風(fēng)扇電路接通,電風(fēng)扇開始轉(zhuǎn)動(dòng),從而起到降溫作用。
4系統(tǒng)的軟件設(shè)計(jì)
本系統(tǒng)采用AT89C51 作為核心處理器件,把經(jīng)過DSl8B20 現(xiàn)場(chǎng)實(shí)時(shí)采集到的溫度數(shù)據(jù),存入AT89C51 的內(nèi)部數(shù)據(jù)存儲(chǔ)器,送液晶顯示,并與預(yù)先設(shè)定值進(jìn)行比較,然后由單片機(jī)輸出信號(hào)去控制風(fēng)扇電路和報(bào)警電路。多功能溫度檢測(cè)顯示系統(tǒng)軟件主要包括:函數(shù)聲明、延遲時(shí)間函數(shù)、DS18B20 初始化函數(shù)、讀出DS18B20 當(dāng)前的溫度、溫度數(shù)據(jù)轉(zhuǎn)化成液晶字符顯示等程序。
5結(jié) 論
隨著工業(yè)的不斷發(fā)展,對(duì)溫度測(cè)量的要求來越高,而且測(cè)量范圍也越來越廣,因此對(duì)溫度檢測(cè)技術(shù)的要求也越來越高。
本文介紹了以DSl8B20 新型數(shù)字溫度傳感器、AT89C51 單片機(jī)、LCD1602 液晶顯示模塊為主體構(gòu)建的溫度檢測(cè)顯示系統(tǒng)。說明了系統(tǒng)硬件電路、系統(tǒng)主程序與各模塊子程序的設(shè)計(jì)。本系統(tǒng)采用的是DALLAS 公司推出的數(shù)字式溫度傳感器DS18B20,無需外加A/D 即可輸出數(shù)字量,把溫度信號(hào)直接轉(zhuǎn)換成串行數(shù)字信號(hào)供微機(jī)處理。因此。該系統(tǒng)具有硬件電路結(jié)構(gòu)簡(jiǎn)單、轉(zhuǎn)換精度高、顯示結(jié)果清晰穩(wěn)定、成本低等顯著優(yōu)點(diǎn)。在諸如糧庫測(cè)溫、智能建筑、中央空調(diào)等多種需要溫度檢測(cè)的場(chǎng)合具有較好的應(yīng)用前景。
外文原文:
Based on SCM multi-functional
temperature testing system design
Glendon
Abstract: Based on SCM′s multi-channel data acquisition system is adopted will come from the sensor signal amplification, linear filtering, After processing maintain synchronous sampling, which converted to digital signal input A/D conversion by SCM Acquisition, Then, SCM and PC to PC communications data to the data storage, post-processing and display. a powerful data processing, visual shows, friendly interface and high performance-price ratio, a wide range of features. can be widely used in industrial control equipment, instruments, and electrical engineering integration, intelligent home and many other fields.
Key words: Multi-channel Data Acquisition Microcontroller
1 Introduction
With the development of society and the technological progress, people pay more and more attention to the importance of temperature detection and display. Temperature detection and status display technology and equipment has been widely applied in industries, products on the market emerge in endlessly. Temperature testing and also gradually adopt the automatic control technology to realize the monitor. This topic is a temperature testing and status of the monitoring system.
2 System solutions
This system USES the monolithic integrated circuit AT89C51 as this system. The whole system, the hardware circuit including power supply circuit, sensor, the temperature display circuit circuit, upper alarm circuit . The alarming circuit can be measured in upper temperature range, screaming voice alarm. The basic principle for the temperature control DSl8B20: when the temperature signal acquisition to after temperature signal sent to handle, AT89C51 temperature to LCD screen, SCM according to initialize the upper temperature setting, namely, if the judgement of temperature than the highest temperature cooling fan is started, If the temperature is less than the lowest temperature setting on alarm device.
3 The system hardware design
3.1 AT89C51 SCM are introduced
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM) and 128 bytes of data random-access memory(RAM). The device is manufactured using ATMEL Co.’s high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pin-out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the ATMEL Co.’s AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.
Features:
·Compatible with instruction set of MCS-51 products;
·4K bytes of in-system reprogrammable Flash memory;
·Endurance: 1000 write/erase cycles;
·Fully static operation: 0 Hz to 24 MHz;
·Three-level program memory lock;
·128×8-bit internal RAM;
·32 programmable I/O lines;
·Two 16-bit Timer/Counters;
·Six interrupt source;
·Programmable serial channel;
·Low-power idle and Power-down modes.
Function Characteristic Description:
The AT89C51 provides the following standard features: 4K bytes of Flash memory, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.
Pin Description:
·VCC: Supply voltage;
·GND: Ground;
·Port 0: Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs.
Port 0 may also be configured to be the multiplexed low order address/bus during accesses to external program and data memory. In this mode P0 has internal pull ups.
Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pull ups are required during program verification.
·Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull ups.
Port 1 also receives the low-order address bytes during Flash programming and verification.
·Port 2: Port 2 is an 8-bit bi-directional I/O port with internal pull ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull ups.
Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory which uses 16-bit addresses (MOVX @ DPTR). In this application, it uses strong internal pull ups when emitting 1s. During accesses to external data memory which uses 8-bit addresses (MOVX @ RI). Port 2 emits the contents of the P2 Special Function Register.
Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.
·Port 3: Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pull ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull ups.
Port 3 also receives some control signals for Flash programming and verification.
·RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
·ALE/: Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input () during Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external Data Memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.
·:Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, is activated twice each machine cycle, except that two activations are skipped during each access to external data memory.
·EA/VPP:External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions.
This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP.
·XTAL1:Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
·XTAL2:Output from the inverting oscillator amplifier.
·Ready/: The progress of byte programming can also be monitored by the RDY/output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY.
Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator. Either a quartz crystal or ceramic resonator may be used.
To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven.
There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide by two flip trigger, but minimum and maximum voltage high and low time specifications must be observed.
Idle Mode:
In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset.
It should be noted that when idle is terminated by a hardware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.
Power-down Mode:
In the power-down mode, the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and special function registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the special function registers but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.
Program Memory Lock Bits:
When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value, and holds that value until reset is activated. It is necessary that the latched value of EA be in agreement with the current logic level at that pin in order for the device to function properly.
Programming the Flash:
The AT89C51 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low-voltage programming mode provides a convenient way to program the AT89C51 inside the user’s system, while the high-voltage programming mode is compatible with conventional third party Flash or EPROM programmers.The AT89C51 is shipped with either the high-voltage or low-voltage programming mode enabled.
The AT89C51 code memory array is programmed byte-by-byte in either programming mode. To program any nonblank byte in the on-chip Flash memory, the entire memory must be erased using the chip erase mode.
Programming Algorithm:
Before programming the AT89C51, the address, data and control signals should be set up according to the Flash programming mode table .To program the AT89C51, take the following steps:
1. Input the desired memory location on the address lines.
2. Input the appropriate data byte on the data lines.
3. Activate the correct combination of control signals.
4. Raise EA/VPP to 12V for the high-voltage programming mode.
5. Pulse ALE/once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 1.5ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached.
Data Polling:
The AT89C51 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data polling may begin any time after a write cycle has been initiated.
Program Verify:
If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verif
收藏