1摘要自从人类开始制造锁以来长期所使用的锁都是机械锁,通俗的讲就是弹子芯锁。而传统的弹子芯锁,由于其本身锁芯密齿的有限加之开锁工具钥匙的容易复制性,使得其安全性大大降低,随着人们生活质量的提高,如何实现安全有效的防盗这一问题受到越来越多人的关注。传统的机械锁由于安全性能太差,被撬的事件屡见不鲜,相比之下,电子密码锁因其保密性强,使用灵活性好,安全系数高,受到了广大用户的欢迎。电子密码锁作为一种新型的锁,不仅拥有海量的密齿,通常从10000到10000000不等,还省去了传统机械锁的钥匙,使用者只要记得其密码,便可以开启,从而大大提高了防盗功能,本文主要设计了一种以单片机89C51为核心的电子密码锁,详细的介绍了该电子密码锁完整的设计过程以及外围的开锁电路和报警电路的设计。电子密码锁主要由三部分组成:键盘接口电路、电子密码锁的控制电路、输出八段显示电路。键盘接口电路包括时序产生电路、键盘扫描电路、弹抖消除电路、键盘译码电路。电子密码锁控制电路设计包括数字按键的数字输入、存储和清除、功能按键的功能设计、移位寄存器的设计和控制、密码清除、变更、存储、报警信号产生电路密码核对、解除电锁电路。输出八段显示电路包括数据选择电路、八段显示器扫描电路。关键词:电子密码锁,89C51,键盘接口,输出八段显示2AbstractEversincemankindstartedmakinglockssincelocksareusedinlong-termmechanicallock,thepopulartalkismarblescorelock.Thetraditionalmarblescorelockcylinderduetoitsownlimitedadditionfine-toothedtoolforunlockingthekeytoeasyreproduction,sotheirsafetyisgreatlyreduced,aspeopleimprovethequalityoflife,howtoachievesafeandeffectiveanti-theftproblembygrowingconcern.Becausetraditionalmechanicallockspoorsafetyperformance,wasacommonoccurrenceprycontrast,electroniclocksforitsconfidentiality,usegoodflexibility,highsafetyfactor,themajorityofusers.Electroniccodelockasanewtypeoflock,notonlyhasamassoffine-toothed,usuallyrangingfrom10,000to10,000,000,alsoeliminatesthetraditionalmechanicalkeytothelock,theuserjustremembertheirpassword,theycanopen,thusgreatlyimprovinganti-theftfeature,thispaperdesigneda89C51microcontrollercorewithanelectroniclock,adetaileddescriptionofthecompleteelectroniclockstounlockthedesignprocessandtheexternalcircuitandalarmcircuit.Electroniccodelockconsistsofthreeparts:thekeyboardinterfacecircuit,electroniclockcontrolcircuit,theoutputBaDuandisplaycircuit.Keyboardinterfacecircuitincludingthetiminggeneratingcircuit,thekeyboardscanningcircuit,bounceeliminationcircuit,thekeyboarddecodercircuit.Electroniccodelockcontrolcircuitdesign,includingdigitalkeydigitalinput,storageandclean,functionaldesignoffunctionkeys,shiftregisterdesignandcontrol,passwordremove,change,tostepdown,storage,alarmsignalgeneratingcircuitpasswordcheck,theliftingpowerlockscircuit.BaDuandisplaycircuitincludingtheoutputdataselectioncircuit,eightoutdisplayscanningcircuit.Keywords:electroniccodelock,89C51,keyboardinterface,theoutputshowseightout3目录第一章绪论.........................................................41.1几种常见的密码锁......................................................................................................41.2研究背景......................................................................................................................41.3国内外研究现状和发展趋势......................................................................................51.4本文研究的主要内容..................................................................................................5第二章方案论证.......................................................62.1方案..............................................................................................................................62.2功能设计及其设计思路..............................................................................................7第三章电路的功能单元设计.............................................73.1AT89C51单片机介绍.................................................................................................73.1.1AT89C51芯片简介.......................................................................................73.1.2引脚说明.....................................................................................................83.2开锁机构....................................................................................................................113.3按键电路设计............................................................................................................123.4显示电路设计............................................................................................................133.5AT24C02掉电存储单元的设计...............................................................................143.5.1AT24C02......................................................................................................143.5.2掉电存储电路............................................................................................153.6密码锁的电源电路设计............................................................................................153.7设计整体电路图........................................................................................................16第四章程序设计......................................................174.1主程序流程图............................................................................................................174.2详细程序....................................................................................................................18结束语...............................................................284第一章绪论1.1几种常见的密码锁1.普通密码锁目前最常用机械锁,这种锁结构简单、使用方便、价格便宜,但在使用中暴露了很多缺点:(1)机械锁是靠金属制成的,通过钥匙上的不同齿形与锁芯的配合来工作的,安全性较低;(2)钥匙一旦丢失,无论谁捡到钥匙都可将门打开2.机械密码锁该型锁将解锁密码以机械装定的形式存储在装置的鉴别机构上,在装置的外围设立密码操作键。密码的输入,产生相应的鉴别动作,即正确的密码输入,鉴别机构产生开锁动作:错误的密码输入,鉴别机构的部件将发生错位或不做出响应。机械密码锁采用机械加工(如精密机械加I/微细加工)制作,皮实、耐用,电磁干扰、外界的异常信号很难启动鉴别机构。但机械密码锁通常包含多个较复杂的机、电功能组件,装置微小型化