I利用数字电路实现电子密码锁学生:XXX指导老师:XXX内容摘要:本数字密码锁采用单片机AT89S52为主控芯片,由EEPROM存储密码。硬件部分包括主控制系统、人机交互界面以及输出系统三大部分。主控制系统中主控制芯片使用了AT89S52单片机,该单片机性能优良,能满足一般的普通应用;EEPROM采用AT24C02芯片,掉电后可以存储密码,从而保证了系统的安全性。人机交互通道部分采用了4×4矩阵键盘输入以及LCD1602标准字符型液晶显示。输出系统部分包括驱动开锁电路和报警电路;其中,在本系统设计中,驱动开锁电路用发光二极管表示,而报警电路则使用蜂鸣器。本系统中使用的AT24C02芯片是一个带有I2C总线接口的EEPROM存储器。I2C总线是一种双向二线制总线,它的结构简单,可靠性和抗干扰性能好。I2C总线结构很简单,只有两条线,包括一条数据线(SDA)和一条串行时钟线(SCL)。具有I2C接口的器件可以通过这两根线接到总线上,进行相互之间的信息传递。本数字密码锁的功能为:密码位数为8位,可选值为0~9,从而保证足够的锁体强度;用户可以自行设定和修改密码;防止密码被盗,输入密码错误次数超过3次则报警;友好的人机界面;输入正确的密码后,驱动开锁电路。软件部分应用单片机C语言实现了本设计的全部控制功能。C语言编译方便,易读性好,且移植性方便,能够满足实现本系统的功能要求。在设计过程中,给出了本系统C语言编程的原理和流程图。本数字密码锁系统稳定性好,设计人性化,由于使用单片机控制并有记忆模块,功能齐全可靠,并有很好的扩展性,而且成本低廉,具有良好的发展前景。关键词:数字密码锁AT24C02芯片安全性IIElectroniccombinationlockAbstract:UsingthedigitalcircuitrealizeelectroniccombinationlockThisdigitallocksUSESthemonolithicintegratedcircuitAT89S52asthecontrollerchip,byEEPROMmemorypassword.Hardwareincludingmastercontrolsystem,man-machineinterfaceandoutputsystemofthree.TheLordcontrolsystemusedinthecontrolchipAT89S52SCM,thissinglechipgoodperformance,cansatisfythegeneralcommonapplication;TheAT24C02chipEEPROM,afterpoweroffcanbestoredpassword,soastoensurethesecurityofthesystem.Man-machineinteractivechannelpartadoptsthe4x4matrixkeyboardinputandLCD1602standardcharactertypeLCDdisplay.Theoutputofsystemincludingdrivecircuitandalarmlockcircuit;Which,inthesystemdesign,drivethelockcircuitusinglight-emittingdiodessaid,andalarmcircuitisusingabuzzer.ThesystemusedAT24C02chipisawiththeI2CbusinterfaceEEPROMmemory.TheI2Cbusisatwo-waytwowirebus,itssimplestructure,reliabilityandanti-interferencecapability.TheI2Cbusstructureissimple,onlytwolines,includingadataline(SDA)andaserialclockline(SCL).HastheI2Cdevicesthroughthisinterfacetotwolinesonthebus,themutualinformationtransfer.Thisdigitallocksfunctionfor:passworddigitsforeight,optionalvalueis0~9,soastoensureenoughlockbodystrength;Theusercansetandmodifythepassword;Topreventthepasswordisstolen,theinputpasswordmistakenumbermorethanthreetimesthealarm;Friendlyhuman-machineinterface;Toenterthecorrectpassword,drivethelockcircuit.ApplicationsoftwareofsinglechipmicrocomputerClanguagerealizedthisdesignofallcontrolfunction.Ccompilerconvenient,easytoreadthegenderisgood,andeasyportability,andcanmeettherequirementofsystemfunctionrealization.Inthedesignprocessaregiven,andthesystemoftheCprogramminglanguageprincipleandflowchart.Thisdigitallockssystemstability,humanizeddesign,becauseuseaIIIsingle-chipmicrocomputercontrolandamemorymodule,completefunctionandreliable,andhaveagoodscalability,andthecostislow,havegooddevelopmentprospect.Keywords:ElectroniccombinationlockAT24C02chipsafetyIV目录前言.....................................................................11系统的硬件设计.........................................................21.1硬件的总体结构和原理...............................................21.1.1硬件系统的总体结构图...........................................21.1.2硬件系统组成...................................................21.1.3系统的可能性分析...............................................31.2单片机AT89S51简介................................................41.2.1主要性能.......................................................41.2.2引脚功能描述...................................................51.3AT24C02简介........................................................71.3.1功能描述.......................................................71.3.2管脚描述.......................................................71.3.3I2C总线协议....................................................81.4LCD1602介绍........................................................81.4.1引脚描述.......................................................91.4.2LCDI602控制指令................................................91.4.3LCDI602读写控制时序...........................................111.54×4矩阵键盘......................................................111.6复位电路..........................................................121.7振荡电路..........................................................121.8发光二极管LED电路................................................131.9报警电路..........................................................131.10电源输入电路.....................................................141.11使用到的元器件列表...............................................152软件程序设计..........................................................152.1编译器KeiluVision2简介..........................................162.2软件总设计流程图..................................................162.3具体功能软件实现..................................................172.3.14×4矩阵键盘扫描程序..........................................17V2.3.2显示程序......................................................192.3.3时钟运行子程序................................................192.3.4时钟时、分修改子程序..........................................202.3.5掉电存储服务程序..............................................212.3.7密码修改子程序................................................233结束语...............................................................24附录1:PCB原理图......................................................26附录2:仿真原理图.....................................