【正文】
統(tǒng)的功能需求分析,以及紅外鑰匙(從機)子系統(tǒng)的硬件電路,設計紅外鑰匙(從機)子系統(tǒng)的軟件結 構圖,如圖 44 所示。 26 圖 45 紅外鑰匙(從機)子系統(tǒng)軟件結構圖 紅外遙控門鎖(主機)子系統(tǒng)軟件結構設計 根據紅外遙控門鎖(主機)子系統(tǒng)的功能需求分析,以及紅外遙控門鎖子系統(tǒng)的硬件電路,設計紅外遙控門鎖子系統(tǒng)的軟件結構圖,如圖 45 所示。 圖 46 紅外遙控門鎖子系統(tǒng)軟件結構圖 紅外鑰匙(從機)主程序框圖 紅外鑰匙(從機)子系統(tǒng) 軟件看門狗 遙控開鎖 紅外發(fā)射 紅外接收 加密 數據存儲 注冊 紅外遙控門鎖(主機)子系統(tǒng) 軟件看門狗 紅外發(fā)射 紅外接收 數據校驗 開鎖、注冊顯示 隨機數產生 解密 27 圖 47紅 外鑰匙(從機)主程序框圖 N Y N N N Y Y Y 開始 系統(tǒng)喚醒上電 系統(tǒng)初始化 循環(huán)記事器賦初 紅外發(fā)射 延時等待接收 收到數據? 信號加密 紅外發(fā)射 延時等待 收到數據? 信號加密 紅外發(fā)射 延時等待 收到數據? 信號加密 紅外發(fā)射 延時等待 收到數據? 結束 系統(tǒng)掉電 28 紅外遙控門鎖(主機)主程序框圖 圖 4- 8外遙控門鎖主程序框圖 N Y Y N Y N Y N N N Y Y Y 開始 系統(tǒng)喚醒上電 系統(tǒng)初始化 延時等待接收完畢 收到數據? 產生隨機碼 紅外發(fā)射 延時等待 收到數據? 解密、數據檢驗 產生隨機碼 m1 延時等待 收到數據? 紅外發(fā)射 延時等待 收到數據? 結束 系統(tǒng)掉電 數據是否正確? 紅外發(fā)射 N Y 紅外發(fā)射 延時等待 收到數據? 解密、數據檢驗 數據是否正確? 產生隨機碼 m2 N 解密、數據檢驗 數據是否正確? 開鎖 29 5 系統(tǒng)調試 調試儀器 調試使用的儀器設備如表 5- 1 所示。 表 5- 1 調試使用的儀器設備 序號 名稱、型號、規(guī)格 數量 備注 1 組裝兼容計算機 1 帶 2 個 9 針串口 2 直流穩(wěn)壓電源 2 5V 3 萬用表 1 4 串口調試 USB- ISP 線 1 5 Keil C51 單片機編譯軟件 美國 Keil Software 公司 6 Proteus ISIS 仿真軟件 英國 Labcenter 公司 7 示波器 1 整體調試 本裝置的調試主要分為硬件調試、軟件調試等兩大部分。 經過初步的分析設計后,在制作硬件電路的同時,調試也在穿插進行。這樣有利于問題的分析和解決,不會造成問題的積累,而且不會因為一個小問題而進行整體電路的檢查,從而可以節(jié)約大量的調試時間。軟件編程中,我是首先完成單元功能模塊的調試,然后進行系統(tǒng)調試,整體上與硬件調試的方法差不多。聯機調試是最重要的一部分,同時也是本裝置成功的關鍵。有許多新問題都不是很容易解決的。 硬件單元調試 紅外鑰匙(從機)調試 當按鍵按下后,系統(tǒng)上電,確保單片機能夠自鎖電子開關,維持電子開關的導通,系統(tǒng)正常供電。在紅外遙控器(鑰匙)軟件尚未編寫的情況下,首先模擬單片機的自鎖操作,發(fā)現電子開關能自鎖,系統(tǒng)正常供電??紤]到按鍵操作時間一般為幾十毫秒到幾秒,單片機復位時間僅為 200ms 左右,一般來得及輸出自鎖高電平。后來軟件編好以后,發(fā)現系統(tǒng)確實能正常上電工作。 紅外遙控門鎖(主機)調試 調試時使用串口 USBISP 線一步步監(jiān)控單片機的紅外反射和接收信號 是否符合要求,來進一步地調整個別電路。紅外遙控門鎖的電路都是經典電路,無須過多調試。 30 軟件調試 對于本系統(tǒng)而言,軟件程序所實現的功能比較多,所以軟件程序的調試顯得相當的煩瑣。整個程序是使用 C語言。 用 51 系列單片機的下載線將程序下載到單片機內,用串口 USB 線來監(jiān)測發(fā)送和接收的數據,對照著來修改程序。首先要保證每個模塊獨立能夠發(fā)送接收的數據均符合要求,再來直接用線來連接從機和主機來測試單片機之間的串口通信協(xié)議是否正確,之后再加上紅外發(fā)送和接收模塊來統(tǒng)一測試。 總結調試經驗,紅外通信只能工作于半雙工 方式,同時,由于通信波特率比較低,編程時應注意等待時間。 6 結論 本系統(tǒng)以單片機 AT89S52 芯片為核心部件,利用紅外通信技術、單片機串口通信技術并配合一套獨特的軟件算法實現了紅外信號傳輸、密碼的隨機加密、序列號的檢測等功能,實驗和理論分析結果都表明,紅外遙控電子密碼鎖設計完成了設計的各項任務。在系統(tǒng)設計過程中,力求硬件線路簡單,充分發(fā)揮軟件片成方便靈活的特點,來滿足系統(tǒng)設計要求。 紅外遙控電子密碼鎖操作簡單,給用戶提供了友好的操作界面,用戶不需專門學習,就能夠簡單、快捷地完成操作,做到即買即用。此產品還 有其它優(yōu)點:功耗低,價格適中,體積?。欢铱梢酝ㄟ^修改單片機程序,從而使其功能不斷地增強與更新。 紅外遙控密碼鎖系統(tǒng)的成本與低、體積小,而且可以進行近距離遙控,低耗很低,可以使用普通堿性電池供電,使用十分方便。如經優(yōu)化設計,成本可以進一步降低。紅外遙控密碼鎖鎖具有廣闊的市場前景。 在畢業(yè)設計過程中,鞏固了在大學 4年內學過的知識,尤其是單片機和模擬電子方面的知識,同時通過這次畢設提高了單片機編程的能力,尤其是獲得的軟件調試經驗,同時加強了我的實際編程能力,同時也讓自己更加的知道了自己知識領域里的不足和缺陷。 由于時間太倉促,經驗不足,理論方面也相應的存在不足,加上條件有限,仍存在著一些設計方面的問題,個人技能也有待提高。理論知識還要鞏固加強。 31 致 謝 首先感謝我的父母親,他們的勤勞善良、執(zhí)著以及對生活的態(tài)度使我終生受益。如果沒有他們從小到大對我的培養(yǎng),就沒有這一切。 感謝我的指導老師許利霞和趙文鋒老師,無論在論文的選題、課題的研究和論文的撰寫過程中,自始至終得到了老師的悉心指導和熱情幫助,使我的畢業(yè)設計才得以順利完成。 感謝學校。學校各位老師這四年來的教導,他們的教導使我受益匪淺。衷心感謝我的舍友謝利洪 同學,感謝他給予我的幫助和支持。感謝 學校圖書館和自修室為我提供了良好的學習環(huán)境,為我不斷吸取新知識提供了很好的源泉。 32 參 考 文 獻 [1]李魯群 . 編寫 Palm J2ME 紅外線 “ 聊天 ” 程序 . [2]李朝青. 1998.單片機原理及接口技術.北京:北京航空航天大學出版社; [3]李朝青 . 機及單片機數據通信技術 .北京航空航天大學出版社; [4]李軍. 2021. 51系列單片機 高級實例開發(fā)指南.北 京航空航天大學出版社; [5]全國大學生電子設計競賽組委會. 2021.全國大學生電子設計競賽獲獎作品選編( 2021).北京:北京理工大學出版社; [6]張文崢 ,李先亮 ,張其善等 . 紅外通信在導航儀中的應用 . 電子技術應用; [7]邱玉春 ,李文俊 . .電子產品世界; [8]楊將新,李華軍,劉到駿等. 2021.單片機程序設計及應用(從基礎到實踐).電子工業(yè)出版社; [9]周立功. 2021. LPC900 系列 Flash 單片機應用技術,北京航空航天大學出版社; [10]周彥明 . 89C2051 系統(tǒng) .電子報; [11]黃耀軍 ,周云 ,嚴國萍等 . . 電子技術; [12]黃智偉. 2021.全國大學生電子設計競賽訓練教程.北京:電子工業(yè)出版社; [13]匿名 . PT2262 實現可遙控式電子密碼鎖 .電子設計應用; [14]薛宗祥,鹿樹理,朱惠英等. 1999. EPSON 8 位單片機原理與應用.北京航空航天大學出版社; [15]Intel corporation. 1981. MCS51(tm) family of single chip microputers: Users manual. Santa Clara: Intel Corporation [16]M Mizumoto. 1995. Realization of PID Controls by Fuzzy Control Methods. Fuzzy Sets and Systems [17]Serial Infrared Physical Layer Specification, Version . October 15,1998,IBM corporation ,HewlettPackard Company, Sharp Inc. [18]Link Management Protocol ,Version 23,1996,IBM Corporation. [19]Serial Infrared Link Access Protocol(IrLAP),Version . June 16, 1996,IBM Corporation , [20]HewlettPackard Company, Apple Computer, Inc., Counterpoint Systems Foundry, Inc. [21]AT24C01 datasheet. 33 The Device of Infrared Electronic Lock in Code Based on single chip Device Tang Jianguo (College of Engineering, South China Agricultural University Guangzhou 510640, China) Abstract: Along with the exaltation of social science and the living level of people, how carry out the family to guard against theft, this problem also change particularly of the simple construct of traditional machine lock,the affairs of theft is electronics lock is safer because of its confidentiality, using the vivid good, the safe coefficient is high, being subjected to the large customer close. The Infrared Electronic lock is a kind of to take the high strength password sequence as the foundation, on board the password switch that carry out in the single slice. It is the information medium with the Infrared, thus carrying out to control from a distance, can also provide with a structure simple contact type munication to connect, and hard to broken. This lock have the usage that convenience, operation simple, and the price cheap etc. so it can bring convenient to the our it is applicable to those special place where is damage of human body, for example high radiation area, high infection area etc. It can carry out the key information to register in the main on board initial attestation, the password information encrypt, the red unauthorized biography lose, and the key throws to lose to discard etc. Go to correspond by letter the principle according to the string between 51 machines, make use of infrared to deliver, this is easy to encrypt and protect to the passwords information the adoption is infrared from a distance outside opposite lock is have more advantage to the electronics bination lock that keyboard input in the machine. For example, infrared ray shoot equip adoption infrared diode, control from a distance shoot the machine is easy to make the production smaller and cheaper。Adopt the numerical signal codes,not only can carry out many controls of the road information, increase the remote control function, raise the anti interference that signal deliver, reduce the mistake action,but also the power consume is low。The infrared ray will not reveal toward outdoors, will not produce a disturb of signal。Respond quickly,the efficiency deliver is high, work stable credibility etc. So the infraredcontrol uses extensive correspondence and controls from a distance the means currently. The software design adoption the design thought from top to bottom, to make the system toward wear distribute type,turn to the direction development of small, strengthen the 34 system and can expand the stability and the result enunciation, various functions of this system are already all request of this design. Key words: Infrared ray, Remote control, Codelock, single chip 附 錄 附錄 1 主要元器件清單 序號 名稱 型號及規(guī)格 數量 1 單片機 AT89S52 2 2 存儲器 AT24C01 2 3 紅外一體化接收頭 TL1838 2 4 紅外發(fā)射二極管 LED 2 5 晶振 2 6 發(fā)光二極管(紅) ED 1 7 發(fā)光二極管(黃) LED 1 8 三極管 9015 4 9 穩(wěn)壓電源 5V 1 10 電池盒 四芯 1 11 萬用板 單面 1 12 撥碼開關 MD8 1 13 按鍵 微動 5 14 ISP 座 DC2- 10P 2 15 排阻 A103G10kΩ 1 16 可調電阻 W103326T1kΩ 2 17 電阻 177。 1% 5 18 電阻 177。 1% 2 19 電阻 177。 1% 2 20 電阻 177。 1% 4 21 電解電容 105℃ 50V22uF177。 20% 2 22 電解電容 105℃ 50V10uF177。 20% 2 23 陶瓷電容 NOP50V33pF177。 10% 4 24 電解電容 NOP50V100pF177。 10% 1 附錄 2 程序清單 /*本設計的程序分為從機和主機兩部分 ,由于篇幅所限,以下程序只給出主程序 */ /*******************************從機主程序 **********************************/ include include include include include include include /* AT89S5X SFR定義 ( ) */ sfr AUXR = 0x8e。 sfr WDTRST = 0xa6。 sfr WDTPRG =0xA7。 sfr16 TIMEER2 = 0xcc。 sfr16 RCAP2 = 0xca。 define WDIDLE (14) sbit KEY_START=P3^3。 sbit LIGHT_REG_OK=P3^7。 sbit OUT_38K =P2^7。