【正文】
******************DS1302: 讀 取 數(shù) 據(jù) ( 先 送 地 址 , 再 讀 數(shù) 據(jù) )**************************/ uchar read_1302(uchar addr) { uchar time。 return(time)。k++)。 sel=0xfe。 //循環(huán)左移 p++。 //端口賦 1,以保證正確掃描按鍵 if(P1_0==0 ) //有鍵按下 { delay(80)。second=sec。 while(P1_3==0)。 } } } } void ScanKey1(void) { P1_1=1。minute=min。minute=min。 ScanKey1()。 //閃爍位加 1 if(timer1[i]==10) timer1[i]=0。 while(moment) { display(timer1)。 } if(i==4) i=0。 timer2[1]4) { timer2[1]=0。TimeString[2]==timer1[2]amp。amp。(secsecond==0)) //判斷沒有按鍵響應(yīng)后一分鐘到否 {mark=1。 大學本科生畢業(yè)設(shè)計(論文) 35 Compare()。 //二進制轉(zhuǎn)化成 BCD 碼形式 if(hou==26) hou=32。 if(min==74) min=80。 //寫時 write_1302(0x82,min)。 while(1) { close()。 min=read_1302(0x83)。 //寫秒 大學本科生畢業(yè)設(shè)計(論文) 36 write_1302(0x8e,0x80)。 } //******************************* 初始化*************************************// void initial() { while(flag[4]==0) { ScanKey1()。 if(flag[2]==1) {min=min+1。 //有按鍵按下時,點亮數(shù)碼管 if(flag[1]==2) mark=0。 //熄滅數(shù)碼管 ScanKey()。amp。TimeString[3]==timer1[3]) { P3_1=0。 while(moment) { display(timer2)。 //閃爍位加 1 if(timer2[i]==10) timer2[i]=0。 } } while(flag[0]==2) //設(shè)置定時時間 2 { ScanKey()。 } if(timer1[0]2) 大學本科生畢業(yè)設(shè)計(論文) 33 { timer1[0]=0。 wait()。} else {flag[2]=2。} } } 大學本科生畢業(yè)設(shè)計(論文) 32 else flag[1]=0。 P1_1=1。 minute=min。minute=min。 //端口賦 1,以保證正確掃描按鍵 if(P1_0==0) //去抖動 大學本科生畢業(yè)設(shè)計(論文) 31 { wait()。0x0f 。k4。 for(i=0。 for(i=0。 //停止工作 T_CLK=0。 //停止工作 T_CLK=0。 for(i=0。 ACC=da。 sbit LED =P3^6。uchar second=0。 uchar mark=0。 本次畢業(yè)設(shè)計我雖然用了較長的時間,但整個過程我都認真的完成了, 而且從中獲得很多。一般情況下,剛焊完的板子基本上會有點小問題,不可能一接上電源就能正常運行的,所以進行硬件調(diào)試時還是必不可少的。amp。TimeString[3]==timer1[3]) { P3_1=0。 while(moment) { display(timer2)。 //閃爍位加 1 if(timer2[i]==10) timer2[i]=0。 } } while(flag[0]==2) //設(shè)置定時時間 2 { ScanKey()。 } if(timer1[0]2) { timer1[0]=0。 wait()。 ( 2)按鍵處理包括了定時時間的設(shè)置和已經(jīng)設(shè)置好了定時時間,按模式切換按鍵可以用來查看剛才設(shè)置好的時間。 if(P1_2==1) {flag[2]=1。} else{flag[1]=2。second=sec。 if(P1_3==0) { P1_3=1。 minute=min。 三 定時器軟件設(shè)計的流程圖 大學本科生畢業(yè)設(shè)計(論文) 16 (圖 10)軟件設(shè)計流程圖 程序如下: void ScanKey() { P1_0=1。 大學本科生畢業(yè)設(shè)計(論文) 15 第四章 飲水機定時器的軟件設(shè)計 一 系統(tǒng)軟件設(shè)計要求 該定時器主要是由 4 部分組成:按鍵電路、時鐘電路、顯示電路和繼電器電路組成。在訪問 8 位地址的外部數(shù)據(jù)存儲器(如執(zhí)行 MOVX R1指令)時, P2口引腳上的內(nèi)容(就是專用寄存器( SFR)區(qū)中 P2 寄存器的內(nèi)容),在整個訪問期間不會改變。作輸入口使用時,因為有內(nèi)部的上拉電阻,那些被外部信號拉低的引腳會輸出一個電流( I)。作為輸出口用時,每位能以吸收電流的方式驅(qū)動 8 個 TTL 輸入,對端口寫 1 時,又可作高阻抗輸入端用。 然而要注意的是:每當訪問外部數(shù)據(jù)存儲器時,將跳過一個 ALE 脈沖。采用外部振蕩器時,此引腳應(yīng)懸浮不連接。 VCC 電源端 時鐘脈沖的個數(shù)在單字節(jié)方式下為 8 加 8( 8 位地址大學本科生畢業(yè)設(shè)計(論文) 11 加 8位數(shù)據(jù)),在多字節(jié)方式下為 8加最多可達 248 的數(shù)據(jù)。并用數(shù)碼管 顯示出從 DS1302 中讀出來的時間 。即: 12986為公共端, a11 b7 c4 d2 e1 f10 g5 dp3。 ( 2) DS1302 時鐘電路:由單片機讀取 DS1302 輸出的時鐘信號。 ( 2)在對循環(huán)定時器功能了解以及選擇好所需硬件設(shè)備的基礎(chǔ)上,根據(jù)所選硬件設(shè)備完成所需原理圖的設(shè)計,以及電路板的設(shè)計。 本文論述的飲水機定時器能夠有效 地解決上述的一些問題,該定時器電路能夠穩(wěn)定實現(xiàn)循環(huán)定時,還能實現(xiàn)自動周期性切斷電源, 控制電器設(shè)備的運行,起到降低成本、節(jié)能環(huán)保、延長電器壽命的作用。人們在日常生活中會需要用到各種定時器的相關(guān) 家電產(chǎn)品,來實現(xiàn)智能化控制電器產(chǎn)品的自動開啟關(guān)閉,因此定時器的使用給人們?nèi)粘I顜砹藰O大的便利。該定時器可以用電子時鐘來顯示時間,并可以在任意時段用該定時器來進行定時。s living standards improve,drinking fountains, electric water heater has bee a family of essential supplies, water dispensers and electric products, such as repeated heating caused thousands of boiling water also affect the health of people hidden. The family does not remend drinking bottled water and drinking fountains, the two long drinking is not good This subject introduction the microcontroller STC89C52 and DS1302 as the core of the water dispenser timer , this timer can be used to solve the drinking fountains and other electric for a long time power caused some problems. This timer can be used to display electronic clock time, and at any time using the timer time. The paper describes the design process of the fountains cycle timer, firstly analyzes and summarizes the timer on how to achieve timing in order to design the overall program, and then use the microcontroller and the clock chip DS1302 timer function, and design timing procedures, and finally through the design of the timer energy saving control and the cycle of regular features. Keywords: Energy control, Cycle time, DS1302 —— 飲水機循環(huán)定時器的設(shè)計 ....................................................................................................... 1 摘要 ............................................................................................................................................. 1 ABSTRACT .................................................................................................................................. 2 大學本科生畢業(yè)設(shè)計(論文) 3 第一章 緒論 ............................................................................................................................... 4 一 本課題的研究意義 ............................................................................................................ 4 二 定時器的發(fā)展現(xiàn)狀 ............................................................................................................ 4 三 本課題的基本任務(wù) ............................................................................................................ 5 第二章 飲水機定時器的設(shè)計方案 ................................................................................................. 6 第三章 飲水機定時器的硬件設(shè)計 .............................................................