Current location - Education and Training Encyclopedia - Graduation thesis - Electronic password lock paper
Electronic password lock paper
Title: Replaceable six-digit electronic password lock. Two. Abstract: Single chip microcomputer technology has a wide range of applications and great potential in the field of intelligent detection and control. This paper expounds the design and implementation of an electronic password lock for liquid crystal display based on single chip microcomputer. The system uses AT89S52 single chip microcomputer of American Atmel company as the core of the system, LCD 1602 as the output device to display the system prompt information, 4*4 matrix film keyboard as the input device, and buzzer, relay and other circuits to form the whole system hardware. The system software is written in assembly language. The designed system has the functions of LCD display, password modification, alarm, locking and so on, which is convenient and simple to use, meets the needs of public locks in residence and office, and has certain practical value. 3. Tasks and requirements: 1 Require the design of electronic password lock (1) Be familiar with the circuit and understand the control flow between components. ② Familiar with the running environment of PROTEUS platform. (3) Master the real-time control operation of assembly language and matrix keyboard. (4) Understand the working principle of electronic password lock. Task 2 (1) Determine the 4× keyboard control identification scheme. (2) Analyze the working process of electronic password lock. 4 (3) Draw the program flow chart. (4) Analyze the circuit diagram. (5) write code. (6) Program analysis and debugging. 4. Design idea: This circuit is a single-chip microcomputer control scheme with AT89C5 1 as the core. Using the flexible programming design of single chip microcomputer, rich IO ports and the accuracy of its control, not only the basic password lock function can be realized, but also the functions of electricity adjustment and storage, acousto-optic prompt and even remote control can be added according to actual needs. V. Establishment of the scheme: In order to realize the confidentiality of the password, the user password (1- 16 bits long) can be set at will by using the 4×4 matrix keyboard, which improves the confidentiality of the password. The design adopts super password. You only need to enter the super password to open the door when you turn it on, which can prevent no password from being available when you turn it off again. Using 1602 liquid crystal as the display unit, the readability is improved and the user can see the operation of the password lock at a glance. Overall design block diagram of intransitive verbs: keyboard input module, password storage module, buzzer alarm circuit, reset circuit, crystal oscillator circuit, liquid crystal display module 8 9 C 5 1 unlocking circuit diagram 2. 1 system structure block diagram 7. Function of each module: 1. Keyboard input module: divided into password input keys and several function keys, used to complete the password lock input function. 2. Password storage module: used to complete the power-off storage function, so that the modified password can still be saved after power-off. 3. Buzzer alarm circuit: used to complete the alarm function when the wrong password is input. 4. Crystal oscillator circuit: used for starting vibration of single chip microcomputer. 5. Reset circuit: complete system reset. 6. Display module: used to display the system status and prompt operation. 7.LED display module: used to assist alarm and input prompt. 8. Unlocking circuit: simulate unlocking with relay and LED to complete unlocking and unlocking prompt. 8. Analysis of design principle: The peripheral circuit of the system consists of keyboard input part, password storage part, reset part, display part, alarm part and unlock part. According to the actual situation, 4× matrix keyboard is selected for keyboard input, LCD 1602 is selected for display, and memory is selected for password storage. Its schematic diagram is as follows: 9. Single chip microcomputer and its peripheral circuits: 1. Reset circuit: 2. Clock circuit: the clock circuit generates timing pulses for the single chip microcomputer, and all the operation and control processes of the single chip microcomputer are driven by unified timing pulses. If the clock circuit of the single chip microcomputer stops working (crystal oscillator stops), then the single chip microcomputer will stop running. When using the internal clock, the connection method is as shown in the following figure: connect a 12MHZ crystal oscillator between the crystal oscillator pins XTAL 1( 19 pin) and XTAL2( 18 pin), and respectively ground a capacitor to generate the required clock signal. The capacitance of the capacitor is generally several tens of picofarads. xta l 1c 1y 1 C2 xtal 23。 The design of matrix keyboard circuit In order to strengthen the confidentiality of passwords, a 4× matrix keyboard can be used to set the user password 4 (1- 16 bit length) at will, thus improving the confidentiality of passwords and reducing the I used when interfacing with single chip microcomputer. The intersection of each row and column is different, but connected by a key. With this determinant matrix structure, only N rows and M columns are needed to form an N × M key matrix keyboard. In this single-chip microcomputer system with determinant matrix keyboard coding, the keyboard processing program first executes the program segment of waiting for the key and confirming whether the key is pressed. When it is confirmed that a key was pressed, the next step is to identify which key was pressed. There are usually two ways to identify keys: one is a general line scanning query method; The other is a faster line inversion method. In this system, we use the line inversion method. Firstly, whether the keys in the keyboard are pressed or not is recognized, and then a full scan word is sent to the keyboard at the I/O port of the single chip microcomputer, and then the line status is read in for judgment. The specific method is: output the full scan word 00H to the row line, set all the column lines to low level, and then read the level state of the column line into the accumulator A. If a button is pressed, there will always be a row line battery pulled to low level, so that the row line is not all 1. Judging which key in the keyboard is pressed is usually achieved by checking the input state of the line after the line is lowered to a low level one by one. The method is to send low levels to the column lines in turn, and then check the status of all the row lines. If they are all 1, the pressed key is not in this column; If it is not all 1, the key pressed must be in this column, and it is the key that intersects with the zero electric parallel line. 4. The 10 number key on the operation panel is used to input the password, and the other six function keys are: Correct, Modify Password and Lock. The function of the correction key is to clear the previously entered data and re-enter the password when it is incorrectly entered. In the password input state, the number keys 0-9 are valid keys, which have the function of time and frequency limitation: there are only three opportunities to input the password, and each time is limited to 10 second. If the password is entered incorrectly or every time it is entered out of time, it is considered as a password entry error. When all three inputs are wrong, the program will return to the initial state. After the password is entered correctly, the relay is engaged, indicating that the lock is opened. When the password is entered correctly, the program enters the state of checking and modifying the password. Press the "Change Password" key to enter the password reset state. When you enter a password, if you find an input error, you can press the "Correct" key to delete and re-enter, and press the "Lock" key to confirm, and the program will exit the password modification state. 5. Liquid crystal display circuit The display circuit designed in this system is set to give users a hint. In order to achieve the purpose of friendly interface, LCD 1602 is used to replace ordinary digital tube. When unlocking, after pressing the unlock key on the keyboard, use the number keys 0-9 on the keyboard to enter the password. Every time a number key is pressed, a * sign will be displayed on the display screen, and how many * signs should be entered. When the password is entered, if the password entered is correct, the LCD will display "OK" and the green light will light up. The P3.0 pin of the single-chip microcomputer will output a low level, which will turn on the transistor T2, attract the electromagnet, trip the relay switch and open the electronic password lock. The password is incorrect, the LCD displays "Error" and P3.0 outputs high level, so the electronic password lock cannot be opened, and the red light is on. Through the LCD screen, the state of the password lock can be clearly judged. Figure 3.7 shows that the circuit display is mainly used to display the following characters, and the instructions are shown in the figure. PaaSWORD Figure 3.8(a) Boot state D Waiting for input state OKPASWORD Input correct state E R R O R password input E R R O R and password input timeout prompt X. System software design The software design of the system adopts assembly language coding. The design method is to write the source code with a text editor first, and then compile it with the software Keil C5 1 If there are no errors, you can connect to generate files in. Hexadecimal format (need to be set in Keil C5 1 in advance). If there is an error, you can't connect, but you can do it in the generated. OBJ file that is easy to modify. Of course, you can also directly use Keil coding. The generated hexadecimal file is an ASCII text file that records text lines. In a hexadecimal file, each line is a hexadecimal record, a machine code or a data constant composed of hexadecimal numbers. Hexadecimal files are often used to store programs or data in ROM and EPROM. Most programmers and emulators use hexadecimal files. 1. The main program of the system main program system is shown in Figure 4- 1. Because the user may press any key at any time while using the system, the program must respond correctly. Start the system initialization display menu-Is the password correct? Y N Check the password, and the keyboard scan prompts the correct unlocking error times plus 1 change the password? N Y prompts an error to save a new password and start password input? N delay 1s D button? Close the lock Y N Y (press f key) y display menu II password input password correctly sign = 1? Password comparisoN N n wrong 3 times? Y lock main program flow chart 2. Initialization and key recognition as shown in Figure 4.2, the initialization of the system includes the setting of stack start address, two timers/counters, LCD display mode, password buffer, some custom data spaces and buzzer. After the system is initialized and the password is read, the LCD displays "Password Control" to prompt the user to enter the password. At this point, the program constantly tests the keys to see if any keys are pressed. If yes, carry out key recognition; If there is no key, or the key is not recognized, R3 assigns 0FFH and jumps to the key test. When a real program is running, it spends most of its time testing keys and waiting for user input. Start the initialization of the key test subroutine system. Is there a button? Is there a delay of 0.5S in reading the password? Key recognition subroutine loads initial password? Did you read successfully? Are you prompted to enter a password for successful identification? Yes, key relocation, no initialization and key recognition flow chart 3. In the unlocking process, the LCD is initialized first, and the password is input. If the password is correct, the unlocking circuit will work. When the appliance is powered on, the unlock indicator light will light up. The unlocking process is shown in the figure. Unlock LCD Initialization Press the unlock key LCD Initialization Input Password to confirm whether the password input procedure is correct? No alarm program was successfully unlocked, and the unlocking flow chart is returned. 4. Encryption processing is shown in the figure. It can be seen that the processing flow of encryption key is similar to that of unlocking key, and it is necessary to check whether the password is correct. If it is wrong, you will be prompted to re-enter, and the password can only be modified if it is entered correctly. Then press the modify key, the password modification program will be called and the password will be modified. During this process, the LCD will display information. Is the startup password correct? No password error. Re-enter a new password without prompting. Re-enter a new password. Compared with the two inputs, the change was successful and the change was encrypted. Figure 5. The liquid crystal display subroutine will be called every time the display content is updated, and its flow is as shown in the figure. Start clearing the display write command, enter IR character address, enter DPTR address+1 character =00H? The character code is sent to P0 port to write data into DR, and then returns to the flow chart of liquid crystal display subroutine. Before updating the display content every time, it is necessary to clear the original display content of LCD. The instruction code of the screen clearing instruction is 0 1H, that is, the P0 port is assigned to 0 1H, and then written into the instruction register IR. The content to be displayed in LCD 1602 is to list the ASCII strings to be displayed in advance according to the character code table built in its controller. Send one character's ASCII code into port P0 at a time, then write it into data register Dr. Finally, add one to the character address, and LCD 1602 will display the characters corresponding to the written ASCII code in turn. Because the displayed strings are different in length, it is agreed that each string ends with 00H; When the program detects that the character code is 00H, it stops writing and returns. The content displayed on the LCD will be kept until the next update. XI。 The source program is as follows: # include "delay. h"/* -。