基于--單片機(jī)設(shè)計(jì)多功能數(shù)字鐘設(shè)計(jì)報(bào)告_第1頁
基于--單片機(jī)設(shè)計(jì)多功能數(shù)字鐘設(shè)計(jì)報(bào)告_第2頁
基于--單片機(jī)設(shè)計(jì)多功能數(shù)字鐘設(shè)計(jì)報(bào)告_第3頁
基于--單片機(jī)設(shè)計(jì)多功能數(shù)字鐘設(shè)計(jì)報(bào)告_第4頁
基于--單片機(jī)設(shè)計(jì)多功能數(shù)字鐘設(shè)計(jì)報(bào)告_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、-多功能數(shù)字鐘設(shè)計(jì)報(bào)告指導(dǎo)教師:龍光利隊(duì)員:霍寶龍物理與電信工程學(xué)院王陽陽電氣工程學(xué)院,電氣101偉濤電氣工程學(xué)院,電氣101目錄1. 設(shè)計(jì)任務(wù)與要求2. 設(shè)計(jì)原理及方案3. 主要元器件清單4. 電路原理圖5. 原理說明6. 系統(tǒng)軟件局部7. 整機(jī)調(diào)整過程8. 總結(jié)六位多功能數(shù)字鐘制作報(bào)告一設(shè)計(jì)任務(wù)與要求。1.任務(wù)。設(shè)計(jì)制作一個(gè)24小時(shí)制多功能數(shù)字鐘。示意圖如下僅供參考:2要求.根本要求1具有時(shí)間設(shè)置小時(shí)和分鐘、鬧鐘時(shí)間設(shè)置、鬧鐘開、鬧鐘關(guān)功能。2數(shù)字顯示小時(shí)、分鐘,有AM、PM指示器,鬧鐘就緒燈,蜂鳴器。3220V供電。發(fā)揮局部1鍵盤切換現(xiàn)場環(huán)境溫度顯示。060 12鍵盤切換電網(wǎng)頻率、電壓顯

2、示。 3電壓欠壓、過壓報(bào)警220V 10功能。二,設(shè)計(jì)原理及方案1,計(jì)數(shù)原理 數(shù)字計(jì)中是一個(gè)對(duì)標(biāo)準(zhǔn)頻率進(jìn)展校準(zhǔn)的計(jì)數(shù)電路。它的計(jì)時(shí)周期是24小時(shí),由于計(jì)數(shù)器的起始時(shí)間不可能與標(biāo)準(zhǔn)時(shí)間一致,所以采用校準(zhǔn)功能和報(bào)時(shí)功能。 數(shù)字鐘電路主要由譯碼顯示器、校準(zhǔn)電路、報(bào)時(shí)電路、時(shí)計(jì)數(shù)、分計(jì)數(shù)、秒計(jì)數(shù)器,振蕩器和單脈沖產(chǎn)生組成。其中電路系統(tǒng)由秒信號(hào)產(chǎn)生器是整個(gè)系統(tǒng)根本信號(hào),它直接決定計(jì)數(shù)器的精度,用石英振蕩器加分頻器來實(shí)現(xiàn),將標(biāo)準(zhǔn)秒信號(hào)送入秒計(jì)數(shù)器。分、秒計(jì)數(shù)器采用60進(jìn)制,時(shí)計(jì)數(shù)器采用24進(jìn)制,。譯碼器顯示電路將時(shí)、分、秒計(jì)數(shù)器的輸出狀態(tài)通過三個(gè)兩位共陽數(shù)碼管顯示出來。整點(diǎn)報(bào)時(shí)電路根據(jù)計(jì)時(shí)系統(tǒng)的輸出狀態(tài)產(chǎn)

3、生一個(gè)脈沖信號(hào),用蜂鳴器輸出。二、模塊電路設(shè)計(jì)與比擬1、 時(shí)鐘方案選擇采用帶 RAM的時(shí)鐘芯片AT89C2051。該芯片可以進(jìn)展時(shí)分秒的計(jì)數(shù),可編程接口,還具有報(bào)警功能和掉電保存功能,并且可以對(duì)其方便的進(jìn)展程序控制,完全能滿足題目的要求。C程序:*include<REG2051.H>code senen_seg10=0*81,0*e7,0*92,0*a2,0*e4,0*a8,0*88,0*e3,0*80,0*a0; /P1.7(冒號(hào))口高電平bit key1_enter=0,key2_enter=0,key3_enter=0,countdown_mark=0,stopwatch_m

4、ark=0,count_mark=0,bell_mark=0; /狀態(tài)標(biāo)志unsigned char program=0,program_variable=0,count_bit=0,count=0;unsigned char hour=10,minute=10,second=0; /時(shí)間變量unsigned char delayed_hour=22,delayed_minute=10,delayed_second=0;/定時(shí)變量unsigned char count_hour=0,count_minute=0,count_second=0; /計(jì)時(shí)計(jì)數(shù)變量unsigned char coun

5、t_time=0,count_count=0; void delay(unsigned int t)/延時(shí)子程序 unsigned int i,j; for(i=0;i<t;i+) for(j=0;j<10;j+) ; void time0_init(void) /定時(shí)計(jì)數(shù)0器初始化EA=0; TR0=0;TMOD=0*01;TH0=0*ec;TL0=0*73;ET0=1;TR0=1;EA=1;static void timer0_isr(void) interrupt TF0_VECTOR using 1 /定時(shí)計(jì)數(shù)0器中斷函數(shù)TR0=0;TH0=0*ec;TL0=0*73;TR

6、0=1;count_time+; /時(shí)鐘計(jì)時(shí)程序if(count_time>=199) count_time=0; second+; if(second>=60) second=0; minute+; if(minute>=60) minute=0; hour+; if(hour>=24)hour=0; if(delayed_hour=hour && delayed_minute=minute && second<4) P3_7=0;else P3_7=1;if(countdown_mark=1) /倒計(jì)時(shí)程序 count_coun

7、t+; if(count_count>=199 && (count_second!=0|count_minute!=0|count_hour!=0)count_count=0;count_second-;if(count_second>=60) count_second=59; count_minute-; if(count_minute>=60) count_minute=59; count_hour-; if(count_hour>=100) count_hour=99; if(count_second=0&&count_minute

8、=0&&count_hour=0&&count_count<=12000) P3_7=0;else P3_7=1;if(count_count>=15000) count_count=14000; if(stopwatch_mark=1) /秒表程序 count_count+; if(count_count>=2)count_count=0;count_second+;if(count_second>=100) count_second=0; count_minute+; if(count_minute>=60) count_min

9、ute=0; count_hour+; if(count_hour>=60) count_hour=0; unsigned char show_key (void)unsigned char *=0,y=0;switch (program)case 0: P1&=senen_segsecond%10; /時(shí)鐘秒的個(gè)位 break;case 1: if(count_time>=90) P1&=senen_segsecond%10; /校正秒的個(gè)位 break;case 2: if(delayed_hour=24) P1=0*fe;/鬧鐘秒的個(gè)位 else P1&

10、;=senen_segdelayed_second%10; break;case 3: if(count_bit>=0) P1&=senen_segcount_second%10;/倒計(jì)時(shí)秒的個(gè)位 else P1=0*ff; break;case 4: P1&=senen_segcount_second%10; /秒表秒的個(gè)位break;case 5: P1&=senen_segcount_second%10; /計(jì)數(shù)器個(gè)位break; P3_3=0; delay(10); if(P3_5=0)/功能鍵1識(shí)別 key1_enter=1;if(count<=2

11、54)count+; if(P3_4=0) key2_enter=1;/功能鍵2識(shí)別 if(P3_2=0) key3_enter=1; /功能鍵3識(shí)別 P3_3=1; P1|=0*ff;switch (program) case 0: P1&=senen_segsecond/10; /時(shí)鐘秒的十位break;case 1: if(count_time>=90) P1&=senen_segsecond/10; /校正秒的十位 break;case 2: if(delayed_hour=24) P1=0*fe; /鬧鐘秒的十位 else P1&=senen_segde

12、layed_second/10; break;case 3: if(count_bit>=1) P1&=senen_segcount_second/10;/倒計(jì)時(shí)秒的十位else P1=0*ff; break;case 4: P1&=senen_segcount_second/10; /秒表秒的十位break;case 5: P1&=senen_segcount_second/10; /計(jì)數(shù)器十位break; P3_1=0; delay(10); P3_1=1; P1|=0*ff;switch (program) case 0: P1&=senen_seg

13、minute%10; /時(shí)鐘分的個(gè)位break;case 1: if(count_time>=90) P1&=senen_segminute%10; /校正分的個(gè)位break;case 2: if(delayed_hour=24) P1=0*fe;/鬧鐘分的個(gè)位 else P1&=senen_segdelayed_minute%10; break;case 3: if(count_bit>=2) P1&=senen_segcount_minute%10;/倒計(jì)時(shí)分的個(gè)位else P1=0*ff;break;case 4: P1&=senen_segc

14、ount_minute%10; /秒表分的個(gè)位break;case 5: P1&=senen_segcount_minute%10; /計(jì)數(shù)器百位break; P3_2=0; delay(10); P3_2=1; P1|=0*ff;switch (program)case 0: P1&=senen_segminute/10; /時(shí)鐘秒的個(gè)位break;case 1: if(count_time>=90) P1&=senen_segminute/10; /校正秒的個(gè)位 break;case 2: if(delayed_hour=24) P1=0*fe;/鬧鐘秒的個(gè)位

15、 else P1&=senen_segdelayed_minute/10; break;case 3: if(count_bit>=3) P1&=senen_segcount_minute/10;/倒計(jì)時(shí)秒的個(gè)位else P1=0*ff;break; case 4: P1&=senen_segcount_minute/10; /秒表秒的個(gè)位break;case 5: P1&=senen_segcount_minute/10; /計(jì)數(shù)器千位break; P3_5=0; delay(10); P3_5=1; P1|=0*ff;switch (program)c

16、ase 0: P1&=senen_seghour%10; /時(shí)鐘時(shí)的個(gè)位break;case 1: if(count_time>=90) P1&=senen_seghour%10; /校正時(shí)的個(gè)位break;case 2: if(delayed_hour=24) P1=0*fe; /鬧鐘時(shí)的個(gè)位 else P1&=senen_segdelayed_hour%10; break;case 3: if(count_bit>=4) P1&=senen_segcount_hour%10;/倒計(jì)時(shí)時(shí)的個(gè)位else P1=0*ff;break;case 4: P

17、1&=senen_segcount_hour%10; /秒表時(shí)的個(gè)位break;case 5: P1&=senen_segcount_hour%10; /計(jì)數(shù)器萬位break; P3_0=0; delay(10); if(P3_4=1 && key2_enter=1) *=3; /確認(rèn)功能鍵2識(shí)別,返回3 key2_enter=0; P3_0=1; P1|=0*ff;switch (program) case 0: P1&=senen_seghour/10; /時(shí)鐘時(shí)的個(gè)位break;case 1: if(count_time>=90) P1&am

18、p;=senen_seghour/10; /校正時(shí)的個(gè)位break;case 2: if(delayed_hour=24) P1=0*fe; /鬧鐘時(shí)的個(gè)位 else P1&=senen_segdelayed_hour/10; break;case 3: if(count_bit>=5)P1&=senen_segcount_hour/10; /倒計(jì)時(shí)時(shí)的個(gè)位else P1=0*ff;break;case 4: P1&=senen_segcount_hour/10; /秒表時(shí)的個(gè)位break;case 5: P1&=senen_segcount_hour/1

19、0; /計(jì)數(shù)器萬位break; P3_4=0; delay(10); if(P3_5=1 && key1_enter=1)/確認(rèn)功能鍵1識(shí)別,執(zhí)行退出或進(jìn)入下一個(gè)功能 if(count>=127) *=1; /確認(rèn)功能鍵1為長按,返回1else *=2; /確認(rèn)功能鍵1為短按,返回2 key1_enter=0;count=0; if(P3_2=1 && key3_enter=1) *=4; /確認(rèn)功能鍵3識(shí)別,返回4 key3_enter=0; P3_4=1; P1|=0*ff;if(program<=1 && count_time&

20、gt;=100) P1&=0*ff;/校時(shí)和顯示功能時(shí)鐘時(shí)冒號(hào)閃爍if(program<=1 && count_time<=100) P1&=0*7f;if(program=2) P1&=0*7f;/設(shè)置鬧鐘功能時(shí)冒號(hào)長亮if(program=3) P1&=0*ff;/設(shè)置倒計(jì)時(shí)功能時(shí)冒號(hào)長滅if(program=4) P1&=0*7f;/設(shè)置秒表功能時(shí)冒號(hào)長亮if(program=5) P1&=0*ff;/設(shè)置計(jì)數(shù)時(shí)冒號(hào)長滅y=*;*=0;return y;void main()/主程序P1=0*ff; P3=0*f

21、f;time0_init();while(1)switch(program)case 0: while(program=0) /時(shí)鐘菜單 switch(show_key() case 0: break;case 1:program=0; break;case 2:program=1; break; break; /校時(shí)菜單case 1: while(program=1)switch(show_key() case 0: break;case 1:program=0; break;case 2:program=2;break;case 3: hour+; if(hour>=24)hour=

22、0;break;case 4: minute+; if(minute>=60)minute=0;break; break;case 2: while(program=2) /鬧鐘菜單 switch(show_key() case 0: break;case 1:program=0; break;case 2:program=3;break;case 3:delayed_hour+;if(delayed_hour>=25)delayed_hour=0;break;case 4:delayed_minute+; if(delayed_minute>=60)delayed_minu

23、te=0;break; break;case 3: while(program=3) /倒計(jì)時(shí)菜單 switch(show_key() case 0: break;case 1:program=0; break;case 2:program=4;break;case 3:count_bit+; if(count_bit>=7)count_bit=0;break;case 4:switch(count_bit) case 0: count_second+=1; break; case 1: count_second+=10; break; case 2: count_minute+=1;

24、break; case 3: count_minute+=10; break; case 4: count_hour+=1; break; case 5: count_hour+=10; break; case 6: break; if(count_hour>=100) count_hour-=100; if(count_minute>=60) count_minute-=60; if(count_second>=60) count_second-=60; break;if(count_bit=6) countdown_mark=1;else countdown_mark=0

25、; break;case 4: count_hour=0;/秒表菜單 count_minute=0;count_second=0; while(program=4) switch(show_key() case 0: break;case 1:program=0; break;case 2:program=5;break;case 3:stopwatch_mark=stopwatch_mark;break;case 4:if(stopwatch_mark=0) count_hour=0; count_minute=0; count_second=0;break; break; /計(jì)數(shù)器菜單ca

26、se 5: count_hour=0; count_minute=0;count_second=0; while(program=5) switch(show_key() case 0: break;case 1:program=0; break;case 2:program=0;break;case 3:count_second+; if(count_second>=100) count_second=0; count_minute+; if(count_minute>=100)count_minute=0; count_hour+; if(count_hour>=100)

27、count_hour=0; break;case 4:count_hour=0; count_minute=0; count_second=0;break;if(P3_7=0)while(P3_7=0) show_key(); count_second+; if(count_second>=100) count_second=0;count_minute+;if(count_minute>=100) count_minute=0; count_hour+; if(count_hour>=100)count_hour=0; break;if(program!=3) countd

28、own_mark=0;if(program!=4) stopwatch_mark=0;2、 電壓有效值方案選擇采用7805五伏穩(wěn)壓電源,電路圖如下:3、 顯示模塊的選擇 采用數(shù)碼管顯示。數(shù)碼管亮度高、體積小、重量輕,但其顯示信息簡單、有限,在此題目中應(yīng)用受到很大的限制。 數(shù)碼管三,主要元器件清單序號(hào)名稱規(guī)格位號(hào)數(shù)量序號(hào)名稱規(guī)格位號(hào)數(shù)量1單片機(jī)AT89C2051U1113三極管9012Q1Q772三端集成穩(wěn)壓78L05U2114電阻220R3R9732位共陽數(shù)碼管紅色0.4寸LED1LED33151KR2、R10R1574發(fā)光二極管紅色3D1D44162KR17、R1825蜂鳴器5V有源U311

29、75.1KR1616瓷片電容30PFC2、C321810KR1170.1uFC4、C5219按鍵6*6*5S1、S2、S3382位排針間距2.54J1J3320電池盒4節(jié)5號(hào)19集成電路插座20PU1121DC插座5.5*2.1110電解電容10uFC1122電源線雙色2P帶熱縮管111100uFC6123電路板105*55112晶振12MHzY1124說明書A4雙面1四、電路原理圖五、原理說明: 1、顯示原理:      顯示局部主要器件為3只兩位一體共陽極數(shù)碼管,驅(qū)動(dòng)采用 PNP 型三極管驅(qū)動(dòng),各端口配有限流電阻,驅(qū)動(dòng)方式為動(dòng)態(tài)掃

30、描,占用 P3.0P3.5 端口,段碼由P1.0P1.6輸出。冒號(hào)局部采用 4 個(gè) 3.0的紅色發(fā)光二極管,驅(qū)動(dòng)方式為獨(dú)立端口P1.7驅(qū)動(dòng)。  2、鍵盤原理:      按鍵 S1S3 采用復(fù)用的方式與顯示局部的 P3.5、P3.4、P3.2 口復(fù)用。其工作方式為,在相應(yīng)端口輸出高電平時(shí)讀取按鍵的狀態(tài)并由單片機(jī)消除抖動(dòng)并賦予相應(yīng)的鍵值。  3、迅響電路及輸入、輸出電路原理:     迅響電路由有源蜂鳴器和 PNP 型三極管組成。其工作原理是當(dāng) PNP 型三極管導(dǎo)通后

31、有源蜂鳴器立即發(fā)出定頻聲響。驅(qū)動(dòng)方式為獨(dú)立端口驅(qū)動(dòng),占用P3.7端口。    輸出電路是與迅響電路復(fù)合作用的,其電路構(gòu)造為有源蜂鳴器,5.1K定值電阻R6,排針J3并聯(lián)。當(dāng)有源蜂鳴器無迅響時(shí)J3輸出低電平,當(dāng)有源蜂鳴器發(fā)出聲響時(shí)J3輸出高電平,J3可接入數(shù)字電路等各種需要。驅(qū)動(dòng)方式為迅響復(fù)合輸出,不占端口。    輸入電路是與迅響電路復(fù)合作用的,其電路構(gòu)造是在迅響電路的 PNP 型三極管的基極電路中接入排針J2。引腳排針可改變單片機(jī)I/O口的電平狀態(tài),從而到達(dá)輸入的目的。驅(qū)動(dòng)方式為復(fù)合端口驅(qū)動(dòng),占用P3.7端口。  4、單片機(jī)系統(tǒng):   本產(chǎn)品采用了單片機(jī)AT89C2051為核心器件,并配合所有的外圍電路,具有上電復(fù)位的功能,無手動(dòng)復(fù)位功能。六、系統(tǒng)軟件局部 為實(shí)現(xiàn)系統(tǒng)功能

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論