




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、畢業(yè)設(shè)計(jì)(論文)-基于at89c51的路燈控制系統(tǒng)設(shè)計(jì) 基于at89c51的路燈控制系統(tǒng)設(shè)計(jì)摘 要本路燈控制系統(tǒng)是針對(duì)實(shí)際情況的需要而進(jìn)行優(yōu)化設(shè)計(jì)的在設(shè)計(jì)中采用開關(guān)按鈕進(jìn)行時(shí)間控制顯示是六位led數(shù)碼管和五個(gè)發(fā)光二極管時(shí)間為正常24小時(shí)走時(shí)可用按鈕調(diào)節(jié)定時(shí)開關(guān)時(shí)間達(dá)到控制的目的發(fā)光二極管為顯示調(diào)時(shí)狀態(tài)及模擬路燈的控制讓本設(shè)計(jì)中更加的形象化該設(shè)計(jì)系統(tǒng)通過對(duì)小時(shí)分鐘和秒鐘的調(diào)整來控制路燈的開關(guān)狀態(tài)并且在23點(diǎn)后路燈會(huì)自動(dòng)熄滅一半達(dá)到節(jié)能的效果啟動(dòng)后進(jìn)入計(jì)時(shí)顯示計(jì)時(shí)用六位數(shù)碼管顯示當(dāng)一天時(shí)間過去后可以循環(huán)繼續(xù)控制用發(fā)光二極管進(jìn)行模擬顯示關(guān)鍵字單片機(jī) 路燈 節(jié)能 控制系統(tǒng)目 錄引言41 系統(tǒng)總體設(shè)計(jì)5
2、11 設(shè)計(jì)要求512 系統(tǒng)組成方框圖52 方案論證521 復(fù)位模塊522 主控模塊623 按鍵輸入模塊624 顯示模塊63 系統(tǒng)硬件設(shè)計(jì)731 總體思路732 各模塊電路圖7com 復(fù)位模塊電路設(shè)計(jì)7com 主控模塊電路設(shè)計(jì)7com 按鍵輸入模塊電路設(shè)計(jì)8com 顯示模塊電路設(shè)計(jì)84 系統(tǒng)軟件設(shè)計(jì)1041 主程序設(shè)計(jì)1042 計(jì)時(shí)程序設(shè)計(jì)1143 中斷程序設(shè)計(jì)125 系統(tǒng)調(diào)試1351 軟件調(diào)試1352 硬件及總體電路調(diào)試1353 系統(tǒng)改進(jìn)方案136 結(jié)束語137 致謝14參考文獻(xiàn)14附錄一 系統(tǒng)總體原理圖 16附錄二 元器件清單 16附錄三 源程序 17引言照明工程迅猛發(fā)展其路燈數(shù)量的增大而且
3、功耗和性能大大提高因而對(duì)路燈定時(shí)器控制的要求比較精確 目前對(duì)路燈控制方法多為人工控制和光控人工控制受惡劣天氣的影響及其他干擾并且巡視困難光控容易受外部環(huán)境干擾靈敏度低且可靠性較差二者均不能實(shí)現(xiàn)控制開關(guān)燈的合理化科學(xué)化從而會(huì)出現(xiàn)開燈早關(guān)燈晚或者開燈晚關(guān)燈早的現(xiàn)象前者會(huì)造成巨大的電能浪費(fèi)后者會(huì)損害城市形象影響社會(huì)治安和交通安全從而影響城市的投資環(huán)境以上難點(diǎn)將直接影響城市照明管理水平而照明管理的高低又將直接影響到城市的市容投資環(huán)境交通安全和社會(huì)治安等這些都是構(gòu)建良好的城市環(huán)境的重要組成部份對(duì)城市的建設(shè)和發(fā)展有著重要的意義總之隨著城市規(guī)模的不斷擴(kuò)大現(xiàn)有的路燈管理的方式方法已遠(yuǎn)遠(yuǎn)不能滿足城市路燈發(fā)展與管
4、理的需要必須依靠現(xiàn)代化的高科技管理手段路燈管理工作需要一個(gè)以計(jì)算機(jī)為核心的自動(dòng)化的管理手段來替代傳統(tǒng)的路燈監(jiān)控系統(tǒng)使整個(gè)城市照明監(jiān)測(cè)決策和管理工作建立在計(jì)算機(jī)信息網(wǎng)絡(luò)平臺(tái)之上因此建設(shè)現(xiàn)代化的路燈監(jiān)控管理系統(tǒng)已迫在眉睫單片機(jī)是在一塊芯片上集成了一臺(tái)微型計(jì)算機(jī)所需的cpu存儲(chǔ)器輸入輸出部件和時(shí)鐘電路等因此它具有體積小使用靈活成本低易于產(chǎn)品化抗干擾能力強(qiáng)可在各種惡劣環(huán)境下可靠地工作等特點(diǎn)特別是它應(yīng)用面廣控制能力強(qiáng)使它在工業(yè)控制智能儀表外設(shè)控制家用電器機(jī)器人軍事裝置等方面得到了廣泛的應(yīng)用本設(shè)計(jì)中正是運(yùn)用單片機(jī)的at89c51作為主控芯片設(shè)計(jì)的路燈控制系統(tǒng)at89c51不但功能強(qiáng)大而且使用方便價(jià)格便宜可
5、以最大限度的降低成本增加計(jì)時(shí)模式和提高計(jì)時(shí)精度該控制系統(tǒng)體積小適用與校園街道小區(qū)等各種場(chǎng)所的路燈控制可以最大限度的滿足人們的生活需要1系統(tǒng)總體設(shè)計(jì)11設(shè)計(jì)要求當(dāng)開機(jī)后經(jīng)過上電復(fù)位時(shí)鐘顯示為120000這時(shí)可以調(diào)整時(shí)分秒按鈕進(jìn)行精確調(diào)整到當(dāng)前時(shí)間進(jìn)行正常走時(shí)開機(jī)后系統(tǒng)內(nèi)部自定義開路燈時(shí)間為180000關(guān)路燈時(shí)間為60000如果不做調(diào)整的話時(shí)間就是下午6點(diǎn)鐘開燈早晨6點(diǎn)鐘關(guān)燈春夏秋冬四季的晝夜并不相等為了更好的節(jié)省電力資源本設(shè)計(jì)中可以進(jìn)行手動(dòng)調(diào)整根據(jù)四季的變化來調(diào)整開路燈和關(guān)路燈的時(shí)間更有效的節(jié)省資源本設(shè)計(jì)中另外的一大特點(diǎn)就是在230000的時(shí)候路燈會(huì)熄滅一半這種設(shè)計(jì)也是為了節(jié)省資源因?yàn)橐股钊遂o的
6、時(shí)候并不需要太多的路燈照明整個(gè)路面只需要點(diǎn)點(diǎn)燈光就行到早晨六點(diǎn)鐘或自己重新設(shè)定的時(shí)間的時(shí)候再關(guān)閉其它的路燈本設(shè)計(jì)的最大優(yōu)點(diǎn)在于不影響路燈照明的情況下達(dá)到了節(jié)能的效果在同樣設(shè)備的路燈中可以節(jié)約一半的電能起到環(huán)保的作用12系統(tǒng)組成方框圖圖1-1系統(tǒng)方框圖2方案論證21復(fù)位模塊方案一基本rc復(fù)位電路該復(fù)位方式為手動(dòng)復(fù)位可分為高電平復(fù)位和低電平復(fù)位電容可避免高頻諧波對(duì)電路的干擾該復(fù)位電路簡(jiǎn)單易行但缺點(diǎn)是在遇到較強(qiáng)干擾或瞬間斷電時(shí)復(fù)位端電容充放電特性變化往往電源低至ram區(qū)數(shù)據(jù)不能保持時(shí)復(fù)位端上仍儲(chǔ)有相當(dāng)?shù)碾姾芍率闺娫措妷夯謴?fù)時(shí)復(fù)位端不能產(chǎn)生復(fù)位信號(hào)而出現(xiàn)死機(jī)或程序跑飛該復(fù)位電路用在復(fù)位精度不是很高的設(shè)
7、計(jì)中1方案二看門狗復(fù)位電路在死機(jī)或程序跑飛時(shí)對(duì)系統(tǒng)進(jìn)行重新置位或者復(fù)位以使系統(tǒng)恢復(fù)正常運(yùn)行的一種專門電路進(jìn)一步提高了單片機(jī)系統(tǒng)的穩(wěn)定性和抗干擾性的能力用于復(fù)位精度要求較高的設(shè)計(jì)中1本設(shè)計(jì)中對(duì)復(fù)位電路的要求精度不需要很高所以選擇的是方案一的rc高電平復(fù)位電路22主控模塊方案一采用at89c2051芯片它體積小管腳少?zèng)]有提供外部擴(kuò)展存儲(chǔ)器與io設(shè)備所需的地址數(shù)據(jù)控制信號(hào)因此利用at89c2051構(gòu)成的單片機(jī)應(yīng)用系統(tǒng)不能在at89c2051之外擴(kuò)展存儲(chǔ)器或io設(shè)備at89c51設(shè)有穩(wěn)態(tài)邏輯可以在低到零頻率的條件下靜態(tài)邏輯支持兩種軟件可選的掉電模式在閑置模式下cpu停止工作但ram定時(shí)器計(jì)數(shù)器串口和中
8、斷系統(tǒng)仍在工作在掉電模式下保存ram的內(nèi)容并且凍結(jié)振蕩器禁止所用其他芯片功能直到下一個(gè)硬件復(fù)位為止對(duì)按鍵處理的重要環(huán)節(jié)是去抖動(dòng)即除按下和抬起瞬間的抖動(dòng)而消除抖動(dòng)后面臨的更大問題就解決按鍵的響應(yīng)問題包括按鍵的一次響應(yīng)一鍵多功能等單片機(jī)的復(fù)位都是靠外部電路來實(shí)現(xiàn)的在時(shí)鐘電路工作后 只要在單片機(jī)的復(fù)位 rst 腳上出現(xiàn)24個(gè)時(shí)鐘振蕩脈沖 也就是2個(gè)機(jī)器周期 以上的高電平單片機(jī)便實(shí)現(xiàn)初始化狀態(tài)復(fù)位因此要想保證單片機(jī)能夠可靠的復(fù)位 在應(yīng)用系統(tǒng)的電路設(shè)計(jì)中 就要使rst引腳保持10ns以上的高電平 使能循環(huán)到復(fù)位狀態(tài)圖3-1復(fù)位電路322主控模塊電路設(shè)計(jì)采用的at89c51芯片對(duì)整個(gè)系統(tǒng)進(jìn)行控制其中p0口
9、控制數(shù)碼管的7段的亮暗情況p2口控制選擇數(shù)碼管的位數(shù)p3口用于控制調(diào)時(shí)指示燈p1口用于按鍵輸入的控制及路燈開關(guān)控制at89c51的芯片管腳圖如圖3-2示圖3-2 at89c51芯片管腳323按鍵輸入模塊電路設(shè)計(jì)整個(gè)按鍵輸入模塊集中在對(duì)時(shí)間的調(diào)節(jié)和手動(dòng)開關(guān)燈上設(shè)計(jì)圖如圖3-3示圖中第一個(gè)按鍵為調(diào)整時(shí)間位可以通過改按鍵調(diào)整時(shí)分秒的切換第二個(gè)按鍵為增加時(shí)間位第三個(gè)按鍵為減少時(shí)間位第四個(gè)按鍵為手動(dòng)開關(guān)路燈位可以關(guān)一路或兩路一起關(guān)圖3-3 按鍵輸入電路324顯示模塊電路設(shè)計(jì)1數(shù)碼管顯示電路設(shè)計(jì)設(shè)計(jì)中采用兩個(gè)四位數(shù)碼管并排來顯示6位時(shí)間通過單片機(jī)的p0p2口同時(shí)控制數(shù)碼管的工作并在po口與數(shù)碼管間接上拉電
10、阻對(duì)數(shù)碼管進(jìn)行保護(hù)同時(shí)也增加了數(shù)碼管的亮度電路如圖3-4所示圖3-4 數(shù)碼管顯示電路2發(fā)光二極管顯示電路設(shè)計(jì)設(shè)計(jì)中采用了5個(gè)發(fā)光二極管其中三個(gè)發(fā)光二極管作為調(diào)節(jié)時(shí)間顯示燈采用下拉示串電阻是為了保護(hù)發(fā)光二極管如圖3-5所示另外兩個(gè)發(fā)光二極管是路燈指示燈分別代表兩路路燈如圖3-6示圖3-5 調(diào)節(jié)時(shí)間顯示燈圖3-6 路燈顯示燈4系統(tǒng)軟件設(shè)計(jì)41主程序設(shè)計(jì)圖4-1 主程序流程圖本軟件設(shè)計(jì)的程序設(shè)計(jì)包括判斷各個(gè)按鈕按下之后能夠?qū)崿F(xiàn)什么功能判斷開燈關(guān)燈的時(shí)間和手動(dòng)控制路燈其中動(dòng)態(tài)顯示是在中斷子程序中進(jìn)行的每一次中斷的時(shí)間為2ms每中斷一次掃描一次實(shí)現(xiàn)動(dòng)態(tài)顯示正常走時(shí)的動(dòng)態(tài)顯示是在t0中斷中進(jìn)行動(dòng)態(tài)掃描的設(shè)
11、置開燈關(guān)燈的時(shí)間是在t1中斷中進(jìn)行動(dòng)態(tài)掃描的主程序流程圖如圖4-1示42 計(jì)時(shí)程序設(shè)計(jì)計(jì)時(shí)程序的設(shè)計(jì)主要用到定時(shí)器的知識(shí)下面我簡(jiǎn)述一下定時(shí)器的一些基礎(chǔ)知識(shí)mcs-51單片機(jī)內(nèi)部有兩個(gè)16位可編程的定時(shí)器計(jì)數(shù)器即定時(shí)器t0和定時(shí)器t1它們既可用作定時(shí)器方式又可用作計(jì)數(shù)器方式定時(shí)器計(jì)數(shù)器的基本部件是兩個(gè)8位的計(jì)數(shù)器其中th1tl1是t1的計(jì)數(shù)器th0tl0是t0的計(jì)數(shù)器拼裝而成在作定時(shí)器使用時(shí)輸入的時(shí)鐘脈沖是由晶體振蕩器的輸出經(jīng)12分頻后得到的所以定時(shí)器也可看作是對(duì)計(jì)算機(jī)機(jī)器周期的計(jì)數(shù)器因?yàn)槊總€(gè)機(jī)器周期包含12個(gè)振蕩周期故每一個(gè)機(jī)器周期定時(shí)器加1可以把輸入的時(shí)鐘脈沖看成機(jī)器周期信號(hào)故其頻率為晶振頻
12、率的112如果晶振頻率為12mhz則定時(shí)器每接收一個(gè)輸入脈沖的時(shí)間為1us圖4-2 定時(shí)器流程圖定時(shí)器計(jì)數(shù)器有四種工作方式方式0方式1方式2方式3其工作方式的選擇及控制都由兩個(gè)特殊功能寄存器tmod和tcon的內(nèi)容來決定用指令改變tmod或tcon的內(nèi)容后則在下一條指令的第一個(gè)機(jī)器周期的s1p1時(shí)起作用當(dāng)為計(jì)數(shù)工作方式時(shí)計(jì)數(shù)值的范圍是125628當(dāng)為定時(shí)工作方式時(shí)定時(shí)時(shí)間計(jì)算公式為28-計(jì)數(shù)初值x晶振周期x12或 28-計(jì)數(shù)初值x機(jī)器周期本次設(shè)計(jì)中用到了t0和t1進(jìn)行中斷控制t0和t1用的都是方式一在中斷子程序中放進(jìn)了顯示程序中斷時(shí)間為2ms可以實(shí)現(xiàn)數(shù)碼管的動(dòng)態(tài)掃描且無閃爍感定時(shí)器流程圖如圖4
13、-2示43 中斷程序設(shè)計(jì)所謂中斷是指在計(jì)算機(jī)執(zhí)行程序過程中當(dāng)出現(xiàn)某種情況如發(fā)生停電和其他情況時(shí)由服務(wù)對(duì)象向cpu發(fā)出中斷請(qǐng)求信號(hào)要求cpu暫時(shí)中斷當(dāng)前程序的執(zhí)行而轉(zhuǎn)去執(zhí)行相應(yīng)的處理程序待處理程序執(zhí)行完畢后再繼續(xù)處理執(zhí)行原來被中斷的程序中斷子程序能實(shí)現(xiàn)時(shí)鐘自動(dòng)走時(shí)功能從而實(shí)現(xiàn)倒計(jì)時(shí)的運(yùn)行在程序設(shè)計(jì)的過程中有著重要的作用中斷程序流程圖如圖4-3示圖4-3 中斷程序流程圖5系統(tǒng)調(diào)試51軟件調(diào)試本設(shè)計(jì)采用的是c語言的編程方式根據(jù)設(shè)計(jì)要求編寫程序并在keil uvision2軟件中進(jìn)行程序編寫的調(diào)試確定編寫上沒有錯(cuò)誤后利用isis 7 professional配合所設(shè)計(jì)的硬件電路進(jìn)行系統(tǒng)的調(diào)試c語言編寫
14、的程序有許多優(yōu)越性1不懂得單片機(jī)的指令集也能夠編寫完美的單片機(jī)程序2無須懂得單片機(jī)的具體硬件也能夠編出符合硬件實(shí)際的專業(yè)水平的程序3c語言對(duì)數(shù)據(jù)進(jìn)行了許多專業(yè)處理避免了運(yùn)行中間異步的破壞等8源程序見附錄三52硬件及總體電路調(diào)試根據(jù)原理圖及pcb圖制作電路板焊接完成后把程序燒寫到at89c51中把芯片插到電路中接入5v電源數(shù)碼管顯示120000并開始正常走時(shí)這時(shí)通過按鍵部分調(diào)節(jié)當(dāng)前時(shí)間開燈時(shí)間和關(guān)燈時(shí)間當(dāng)時(shí)間到達(dá)相應(yīng)時(shí)間時(shí)路燈自動(dòng)開關(guān)并在230000路燈會(huì)熄滅一半如果沒有設(shè)定開關(guān)燈時(shí)間路燈則在180000時(shí)開啟060000時(shí)熄滅調(diào)試中起初數(shù)碼管出現(xiàn)的全是8而且不受按鍵的控制這是由于初始值設(shè)定中出
15、現(xiàn)了錯(cuò)誤設(shè)置了高電平有效導(dǎo)致數(shù)碼管一直處于點(diǎn)亮狀態(tài)通過把初始值設(shè)置為低電平數(shù)碼管出現(xiàn)正常其次出現(xiàn)了按鍵的不靈敏這是由于按鍵的延時(shí)消抖沒有處理好修改了延時(shí)時(shí)間的長(zhǎng)短按鍵出現(xiàn)正常53系統(tǒng)改進(jìn)方案在本設(shè)計(jì)中首先存在不足的是斷電保護(hù)為了在斷電的情況下系統(tǒng)也能夠正常工作在電源供電方面進(jìn)行改進(jìn)用一組備用電池與電源并聯(lián)通過繼電器連接繼電器有常開常閉觸點(diǎn)繼電器線圈未通電時(shí)處于斷開狀態(tài)的靜觸點(diǎn)稱為常開觸點(diǎn)處于接通狀態(tài)的靜觸點(diǎn)稱為常閉觸點(diǎn)從剛確定畢業(yè)設(shè)計(jì)課題以來我首先是查找一些相關(guān)的書籍及資料然后分析設(shè)計(jì)并根據(jù)實(shí)際情況擬定設(shè)計(jì)方案從而達(dá)到優(yōu)化方案在研究設(shè)計(jì)電路時(shí)我優(yōu)化了電路設(shè)計(jì)這就省去了一部分時(shí)間最難的是調(diào)試了但
16、在老師和同學(xué)的幫助下完成的設(shè)計(jì)達(dá)到了預(yù)定的要求同時(shí)通過這次畢業(yè)設(shè)計(jì)我們?cè)诟鱾€(gè)方面都有了很大的提高特別是在理論和實(shí)踐結(jié)合方面使我們受益匪淺使大學(xué)里學(xué)習(xí)的理論知識(shí)在根本上得到一次最完整的實(shí)踐和提高也為我即將面臨的工作奠定了很好的基礎(chǔ)同時(shí)在本次畢業(yè)設(shè)計(jì)中深深認(rèn)識(shí)到自己的各個(gè)方面的不足之處本著提高動(dòng)手能力以及檢測(cè)四年所學(xué)知識(shí)的目的我嚴(yán)格要求自己每一環(huán)節(jié)都認(rèn)真對(duì)待定期向知道老師報(bào)告進(jìn)展情況和請(qǐng)教不懂的地方得以完成任務(wù)在以后的工作中我們必須進(jìn)一步深化在實(shí)踐中去豐富理論完善知識(shí)結(jié)構(gòu)由于環(huán)境條件的影響理論與實(shí)踐還是有一定的差距這也要求我們?cè)趯?shí)踐中注意檢驗(yàn)的積累7致謝首先感謝我的指導(dǎo)老師張衛(wèi)平老師在做畢業(yè)設(shè)計(jì)和
17、論文的撰寫過程中他給予了悉心的指導(dǎo)和耐心教誨在他的悉心指導(dǎo)下我的畢業(yè)設(shè)計(jì)和畢業(yè)論文得以順利完成在我讀書的四年中物理與機(jī)電工程學(xué)院的老師們對(duì)我的學(xué)習(xí)生活給予了很大的幫助在整個(gè)學(xué)習(xí)階段中老師嚴(yán)謹(jǐn)?shù)闹螌W(xué)態(tài)度和以身作則勤奮塌實(shí)的工作作風(fēng)使我受益菲淺在此表示我深深的謝意同時(shí)我還要感謝實(shí)驗(yàn)室的所有的老師在畢業(yè)設(shè)計(jì)的進(jìn)展中他們給了我很多的關(guān)心和幫助為我們創(chuàng)造一個(gè)良好的研究學(xué)習(xí)環(huán)境還要感謝和我一起學(xué)習(xí)的電本班同學(xué)們?cè)谝黄鹚哪甑膶W(xué)習(xí)和探討給我留下了許多難忘的回憶在此祝他們?cè)谖磥淼臍q月里生活幸福我將努力工作用所學(xué)到的知識(shí)為社會(huì)服務(wù)以出色的工作成績(jī)來回報(bào)學(xué)校老師和家人參考文獻(xiàn)1 賈正松單片機(jī)系統(tǒng)復(fù)位電路設(shè)計(jì)j中國(guó)期
18、刊全文數(shù)據(jù)庫方龍肖獻(xiàn)保李威關(guān)于消除按鍵機(jī)械抖動(dòng)的研究廣西輕工業(yè)2008年1月第1期王春武李巖孟祥英c51中對(duì)按鍵的處理方法吉林師范大學(xué)學(xué)報(bào) 自然科學(xué)版 2007年11月第4期httpbcomview39560htm7 黃皎劉建國(guó)高敏單片機(jī)c語言編程應(yīng)注意的若干問題j微計(jì)算機(jī)信息2003年19卷第7期8 梁合慶使用單片機(jī)c語言的好處j電子產(chǎn)品世界2000109 何立民mcs51系列單片機(jī)應(yīng)用系統(tǒng)設(shè)計(jì)m北京航空航天大學(xué)出版社199010 譚浩強(qiáng)c程序設(shè)計(jì) 第三版 m清華大學(xué)出版社20057at89c51-based control system design of the streetcolleg
19、ephysics mechanical electrical engineeringprofessionelectronic information engineering number2005040202 authorchen juan teacherzhang wei pingabstractthe street lamp control system for the needs of the actual situation to optimize the design in the design using the time switch button control led digi
20、tal display is the six tubes and five light-emitting diode the time for the normal 24-hour travel time can be opened from time to time adjust buttons to control led to show when the state transferred control of street lamps and simulation so the more figurative designs the design system of hours min
21、utes and seconds to adjust the switch to control the state of street lamps and 23 oclock the street lamps will automatically extinguish half to energy-saving effect after start time shows that the digital time display with six when the day cycle of the past can continue to control and use light-emit
22、ting diodes to simulate the displaykeywordsingle-chip street lights energy saving control system器件名稱器件型號(hào)數(shù)量單片機(jī)ac89c511晶振12m1四聯(lián)數(shù)碼管共陰型2發(fā)光二極管5按鍵5磁介電容30pf21042電解電容470uf222uf1電阻1k5470歐5200歐1排阻5111電源5v1附錄三源程序include reg51hunsigned char code changled10 0x3f0x060x5b0x4f0x660x6d0x7d0x270x7f0x6f 共地接的ledunsigne
23、d char led6用來顯示用的unsigned char guandeng3關(guān)開燈的時(shí)間unsigned char kaideng3燈開燈的時(shí)間unsigned char present_time3燈開燈的時(shí)間unsigned char xiao3燈關(guān)小的時(shí)間unsigned char flash 0片選掃描多少時(shí)間換一個(gè)位顯示unsigned char timemeasure 0t1中斷次數(shù)計(jì)算 4020 1秒unsigned char flash_cs 0片選哪個(gè)位sbit dadeng p14燈關(guān)小一點(diǎn)的控制sbit xiaodeng p15燈大的控制aunsigned char t
24、iaozheng 0調(diào)整燈關(guān)開暗的狀態(tài)bit enablebit 0unsigned int enabletime 0sbit p1_0 p10sbit p1_1 p11sbit p1_2 p12sbit p1_3 p13調(diào)整時(shí)間 1為調(diào)整目前的時(shí)間2為調(diào)整關(guān)燈時(shí)間3為調(diào)整秒 void change_data unsigned char i unsigned char xchange if i 1 x present_time0 change x100 x present_time0 led0 x10-change10 x present_time0 led1 unsigned char x-
25、change100-led010 x present_time1 change x100 x present_time1 led2 x10-change10 x present_time1 led3 unsigned char x-change100-led210 x present_time2 change x100 x present_time2 led4 x10-change10 x present_time2 led5 unsigned char x-change100-led410 if i 2 x kaideng0 change x100 x kaideng0 led0 x10-c
26、hange10 x kaideng0 led1 unsigned char x-change100-led010 x kaideng1 change x100 x kaideng1 led2 x10-change10 x kaideng1 led3 unsigned char x-change100-led210 x kaideng2 change x100 x kaideng2 led4 x10-change10 x kaideng2 led5 unsigned char x-change100-led410 if i 3 x guandeng0 change x100 x guandeng
27、0 led0 x10-change10 x guandeng0 led1 unsigned char x-change100-led010 x guandeng1 change x100 x guandeng1 led2 x10-change10 x guandeng1 led3 unsigned char x-change100-led210 x guandeng2 change x100 x guandeng2 led4 x10-change10 x guandeng2 led5 unsigned char x-change100-led410 改變燈的狀態(tài)void change_deng
28、 unsigned i if i 0 dadeng 1 xiaodeng 0 if i 1 dadeng 0 xiaodeng 1 if i 2 dadeng 0 xiaodeng 0 秒分時(shí)進(jìn)初始化void init void guandeng0 660000 guandeng1 0 guandeng2 0 kaideng0 18 kaideng1 0 kaideng2 0 present_time0 12 present_time1 00 present_time2 00 xiao0 23 xiao1 00 xiao2 00 定時(shí)器0t0_in interrupt 1 using 3 un
29、signed char bb flash enabletime if flash 15 flash 0 if flash_cs 0 p2 254 if flash_cs 1 p2 253 if flash_cs 2 p2 251 if flash_cs 3 p2 247 if flash_cs 4 p2 239 if flash_cs 5 p2 223 bb ledflash_cs p0 changledbb if flash_cs 5 flash_cs else flash_cs 0 if enabletime 555 enabletime 0 enablebit 1 定時(shí)器1t1_in i
30、nterrupt 3 using 3 th1 65535-40000 25640ms中斷一次tl1 65536-40000 256tr1 1timemeasure秒分時(shí)進(jìn)判斷鐘if timemeasure 25 4050 1s timemeasure 0 if present_time2 59 present_time2 else present_time2 0 if present_time1 59 present_time1 else present_time1 0 if present_time0 23 present_time0 else present_time0 0 if tiao
31、zheng 3 change_data 1 if present_time0 guandeng0 if present_time1 guandeng1 if present_time2 guandeng2 xiaodeng 0 dadeng 0 if present_time0 kaideng0 if present_time1 kaideng1 if present_time2 kaideng2 xiaodeng 1 dadeng 1 if present_time0 xiao0 if present_time1 xiao1 if present_time2 xiao2 xiaodeng 1
32、 dadeng 0 main unsigned char dengstate 0燈的狀態(tài)p3 0p1 0x00et0 1et1 1tmod 0x12th0 0tl0 0tr0 1th1 65535-40000 25620ms中斷一次tl1 65536-40000 256tr1 1ea 1init change_data 1 init initt for 大小燈轉(zhuǎn)換 if p1_3 1 if enablebit 1 enablebit 0 enabletime 0 change_deng dengstate if dengstate 2 dengstate else dengstate 0 調(diào)整
33、時(shí)間if p1_0 1 if enablebit 1 enablebit 0 enabletime 0 tiaozheng if tiaozheng 0 if tiaozheng 3 change_data 1 if tiaozheng 3 if tiaozheng 6 change_data 2 if tiaozheng 6 if tiaozheng 9 change_data 3 if tiaozheng 10 tiaozheng 0p3 0 if tiaozheng 1 tiaozheng 4 tiaozheng 7 p3 1 if tiaozheng 2 tiaozheng 5 tia
34、ozheng 8 p3 2 if tiaozheng 3 tiaozheng 6 tiaozheng 9 p3 4 if p1_2 1 if enablebit 1 enablebit 0 enabletime 0 if tiaozheng 1 if present_time0 23 present_time0elsepresent_time0 0change_data 1 if tiaozheng 2 if present_time1 59 present_time1elsepresent_time1 0change_data 1 if tiaozheng 3 if present_time
35、2 59 present_time2elsepresent_time2 0 change_data 1 開燈時(shí)間調(diào)整 if tiaozheng 4 if kaideng0 23 kaideng0elsekaideng0 0change_data 2 if tiaozheng 5 if kaideng1 59 kaideng1elsekaideng1 0change_data 2 if tiaozheng 6 if kaideng2 59 kaideng2elsekaideng2 0 change_data 2 if tiaozheng 7 if guandeng0 23 guandeng0el
36、seguandeng0 0change_data 3 if tiaozheng 8 if guandeng1 59 guandeng1elseguandeng1 0change_data 3 if tiaozheng 9 if guandeng2 59 guandeng2elseguandeng2 0 change_data 3 if p1_2 1 if enablebit 1 enablebit 0 enabletime 0 if tiaozheng 1 if present_time0 23 present_time0elsepresent_time0 0change_data 1 if
37、tiaozheng 2 if present_time1 59 present_time1elsepresent_time1 0change_data 1 if tiaozheng 3 if present_time2 59 present_time2elsepresent_time2 0 change_data 1 開燈時(shí)間調(diào)整 if tiaozheng 4 if kaideng0 23 kaideng0elsekaideng0 0change_data 2 if tiaozheng 5 if kaideng1 59 kaideng1elsekaideng1 0change_data 2 i
38、f tiaozheng 6 if kaideng2 59 kaideng2elsekaideng2 0 change_data 2 if tiaozheng 7 if guandeng0 23 guandeng0elseguandeng0 0change_data 3 if tiaozheng 8 if guandeng1 59 guandeng1elseguandeng1 0change_data 3 if tiaozheng 9 if guandeng2 59 guandeng2elseguandeng2 0 change_data 3 if p1_1 1 if enablebit 1 e
39、nablebit 0 enabletime 0 if tiaozheng 1 if present_time0 1 present_time0-elsepresent_time0 23change_data 1 if tiaozheng 2 if present_time1 1 present_time1-elsepresent_time1 59change_data 1 if tiaozheng 3 if present_time2 1 present_time2-elsepresent_time2 59 change_data 1 開燈時(shí)間調(diào)整 if tiaozheng 4 if kaid
40、eng0 1 kaideng0-elsekaideng0 23change_data 2 if tiaozheng 5 if kaideng1 1 kaideng1-elsekaideng1 59change_data 2 if tiaozheng 6 if kaideng2 1 kaideng2-elsekaideng2 59 change_data 2 if tiaozheng 7 if guandeng0 1 guandeng0-elseguandeng0 23change_data 3 if tiaozheng 8 if guandeng1 1 guandeng1-elseguande
41、ng1 59change_data 3 if tiaozheng 9 if guandeng2 1 guandeng2-elseguandeng2 59 change_data 3 龍巖學(xué)院物理與機(jī)電工程學(xué)院畢業(yè)設(shè)計(jì) 論文 外文資料翻譯系 院 物理與機(jī)電工程學(xué)院 專 業(yè) 電子信息工程 姓 名 陳 娟 學(xué) 號(hào) 200504022 外文出處 httpcomicasppdf viewaspid 709719_888800 指導(dǎo)老師 張衛(wèi)平 職 稱 講師 附 件 1外文原文2外文資料譯文 指導(dǎo)教師評(píng)語簽名 2009 年 月 日附件一外文資料原文來源于httpcomicasppdf_viewaspid
42、709719_888800ds1302 trickle charge timekeeping chip一features1real time clock counts seconds minutes hours date of the month month day of the week and year with leap year compensation valid up to 2100231 x 8 ram for scratchpad data storage3serial io for minimum pin count42055v full operation5uses les
43、s than 300 na at 20v6singlebyte or multiplebyte burst mode data transfer for read or write of clock or ram data78pin dip or optional 8pin soics for surface mount8simple 3wire interface9ttlcompatible vcc 5v 10optional industrial temperature range 40c to 85c11ds1202 compatiblepin assignment三pin descri
44、ptionx1 x232768 khz crystal pinsgndgroundrstresetiodata inputoutputsclkserial clockvcc1 vcc2power supply pins四description the ds1302 trickle charge timekeeping chip contains a real time clockcalendar and 31 bytes of static ram it communicates with a microprocessor via a simple serial interface the r
45、eal time clockcalendar provides seconds minutes hours day date month and year information the end of the month date is automatically adjusted for months with less than 31 days including corrections for leap year the clock operates in either the 24hour or 12hour format with an ampm indicator interfac
46、ing the ds1302 with a microprocessor is simplified by using synchronous serial communication only three wires are required to communicate with the clockram 1 rst reset 2 io data line and 3 sclk serial clock data can be transferred to and from the clockram 1 byte at a time or in a burst of up to 31 b
47、ytes the ds1302 is designed to operate on very low power and retain data and clock information on less than 1 microwattthe ds1302 is the successor to the ds1202 in addition to the basic timekeeping functions of the ds1202 the ds1302 has the additional features of dual power pins for primary and back
48、up power supplies programmable trickle charger for vcc1 and seven additional bytes of scratchpad memory1operationthe main elements of the serial timekeeper are shown in figure 1 shift register control logic oscillatorreal time clock and ramds1302 block diagram figure 12signal descriptions vcc1 vcc1
49、provides low power operation in single supply and battery operated systems as well as low power battery backup in systems using the trickle charger the rechargeable energy source is connected to this pinvcc2 vcc2 is the primary power supply pin in a dual supply configuration vcc1 is connected to a b
50、ackup source to maintain the time and date in the absence of primary powerthe ds1302 will operate from the larger of vcc1 or vcc2 when vcc2 is greater than vcc1 02v vcc2 will power the ds1302 when vcc2 is less than vcc1 vcc1 will power the ds1302sclk serial clock input sclk is used to synchronize data movement on the serial interf
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 生態(tài)系統(tǒng)中的能量流動(dòng)與轉(zhuǎn)換試題及答案
- 2024年CPMM時(shí)間規(guī)劃試題及答案
- 傳染病院感防控課件
- 人類自身基因組與健康的關(guān)系試題及答案
- 2025年強(qiáng)振加速度儀合作協(xié)議書
- 出血熱培訓(xùn)知識(shí)課件
- 關(guān)于2024年CPMM的試題及答案
- 自我提升與國(guó)際物流師試題及答案
- 2024年CPMM深入學(xué)習(xí)試題及答案
- 2024年CPMM成功秘訣試題及答案
- 干細(xì)胞與干細(xì)胞治療
- 春季常見傳染病預(yù)防知識(shí)培訓(xùn)
- 中建履帶吊安拆安全專項(xiàng)施工方案
- 醫(yī)學(xué)論文格式與寫作課件
- 市場(chǎng)監(jiān)監(jiān)督管理執(zhí)法講座
- 2024年天翼云從業(yè)者認(rèn)證考試題庫大全(含答案)
- 煤礦開采安全管理培訓(xùn)課件
- 2024年度博物館展覽設(shè)計(jì)合同
- 胰島素皮下注射標(biāo)準(zhǔn)解讀
- 出售渣土合同范例
- 2024年甘肅省高考地理試卷(含答案逐題解析)
評(píng)論
0/150
提交評(píng)論