0. Introduction
Electronic password locks are commonly used encryption tools in modern life. They overcome the shortcomings of mechanical password locks, such as small passwords and poor security performance, especially the intelligent electronic password locks; they not only have the functions of electronic password locks, but also introduce intelligent management functions, making the password locks more secure and reliable.
Electronic password locks are usually controlled by ARM and single-chip microcomputers. Compared with ARM, single-chip microcomputers are simpler to implement and have more complete functions, so single-chip microcomputers are more commonly used. Code locks controlled by single-chip microcomputers are often programmed in assembly language, and most displays are in C. The electronic password lock introduced in this article is written in C language, a high-level language with strong portability and readability, which is convenient for modification and addition and subtraction of functions. At the same time, it uses a clear digital tube, a liquid crystal display with low power consumption and long life, and the display is more intuitive and more convenient to use. From the perspective of economy and practicality, an electronic password lock with password setting, alarm and prevention of multiple password attempts is designed using STC89C52 single-chip microcomputer, and it is successfully simulated by Protues software.
1. System working principle
This system uses STC89C52 microcontroller as the core, uses 4X4 matrix keyboard as data input mode, drives 1602 display to prompt the program running process and * steps. The password judgment process of this system is as follows:
When the user enters a 6-digit password and presses the BESURE key, the microcontroller compares the passwords one by one. If the entered 6-digit honey code is exactly the same as the set password, the *simulation light can be successfully driven to open the lock. If the entered 6-digit password is different from the set password, after pressing the BESURE key, the simulation light will not light up, and you can press the BACK key to re-enter it. Since input errors are inevitable during the password input process, if the password is entered incorrectly, you can directly press the BACK key to re-enter it, but the system does not allow unlimited pressing of the BACK key to prevent the password from being applied. When the password is entered incorrectly 3 times, the microcontroller will drive the buzzer to alarm. In addition, this system has a time limit for entering the password. If the correct password is not entered within the specified time, an alarm will also be triggered.
The password modification function is as follows: when the password is entered correctly, press the SET key to set a new password. Each time a new password is set, the microcontroller sends it to the EPROM. When all 6 new passwords are entered, the system will automatically return to the beginning of the program, re-read the password and save it. The user needs to enter a new password to open the lock.
2. System design
The components used are: core chip STC89C52, memory chip AT24C02, LCD display 1602, matrix keyboard, alarm buzzer, independent button (simulating door switch), light emitting diode (simulating lock switch) and transistor (amplifying current).
2.1 Hardware Support
2.2 Software Design
The system software package includes main program module, code comparison and judgment module, password modification module, keyboard scanning module, LCD display module and timing program module. The system program flow is shown in Figure 1.
Figure 1 System program flow chart
2.2.1 Main program module
The main lease sequence is mainly used to define global variables, assign initial values to global variables, initialize EPROM, start the timer, and read the password from AT24C02 to provide data for the entire program.
2.2.2 Password comparison module
The function of this module is to compare the password input by the keyboard with the set password one by one using IF statements. If the password is completely correct, it will be *; if incorrect, press the BACK key and re-enter the password. Each time the BACK key is pressed, the number of inputs will increase by 1. When all 3 errors are made, an alarm will be triggered.
2.2.3 Password modification module
When the password is entered correctly, you can press SET to reset the password. Each time you set a digit, the password will be sent to AT24C02 for storage. When the 6-digit password is set, the system will automatically jump to the beginning of the program and call the newly set password.
STC89C52 writes password to AT24C02 subroutine: void wrtte_byte (uchar date)
STC89C52 reads the password subroutine from AT24C02:
2.2.4 Keyboard Scanning Module
The module has the following functions: scanning the specific positions of the keys pressed column by column, judging whether any keys are pressed, eliminating jitter, judging whether the closed keys are released, etc.
2.2.5 Timing module
This module is used to control the password input time. When the program is running, the timer is initialized first. When the PUT IN key is pressed, the system starts timing. When the input time reaches the specified time, an alarm will be triggered immediately.
2.2.6 LCD display module
This module includes LCD initialization, command input, and display data input. The command is used to control whether the LCD displays the cursor, whether the cursor flashes, whether to clear the original data, and the specific display position. Data display mainly requires that the information to be displayed be displayed on time.
3 System Simulation
In order to facilitate the program height, this paper adopts Protues simulation, and the simulation diagram is shown in Figure 2.
3.1 System Introduction
In Figure 2, U1 is STC89C52, which is the core of the system. The written program is imported into it as a binary file; U2 is AT24C02, and the 5th and 6th pins are connected to P1.2 and P1.3 of the microcontroller respectively; LCD1 is a 1602 liquid crystal display, and the pin connection is shown in Figure 2; the independent button DOOR is in the key pressed state when the door is closed; D1 is an analog * light, and when the password is correct, press the BESURE key and D1 will light up; BUZ1 is a buzzer alarm. After the program is written and imported into the microcontroller, press the start button at the bottom of Figure 2, the 1602 liquid crystal display will prompt the running status of the password lock, and the system starts working.
3.2* Function
When the power is turned on, the 1602 LCD displays the Welcome interface. When the PUT IN button is pressed, the display shows PUT IN CODES prompting the user to enter the password, as shown in Figure 3. After a few seconds, the prompt on the LCD will automatically disappear. Now you can enter the correct password, and the password will be displayed while entering the password, but the entered data will not be displayed. When the password is entered, press the BESURE button. If the password is correct, D1 will light up (D1 is an analog switch for *). If the password is wrong, you can press the BACK button, the program will jump to the loop (start interface), re-enter the password, and the number of inputs will increase by one. If the input is wrong for 3 times, an alarm will be automatically triggered, and the time to enter the password must be completed within the specified time, otherwise an alarm will be triggered.
3.3 Password Setting
After the password is entered correctly, press the SET button to reset the password, and the LCD will display SET CODS. The prompt will automatically disappear after a few seconds, and the password reset will begin. During the password setting process, the set digits will be displayed. Each time you enter a password, you need to press the YES button to confirm. When the set password reaches 6 digits, it will automatically return to the startup interface.
4. Conclusion
(1) Successfully simulated and realized the functions of 1602 LCD display, password *, password setting, prevention of multiple attempts, alarm, etc.
(2) Programs are written in C language, which has strong portability and facilitates system additions, deletions and modifications.
Previous article:Design of intelligent car based on 80C51 single chip microcomputer
Next article:Implementation of serial communication between PC and single chip microcomputer based on duplex mode
Recommended ReadingLatest update time:2024-11-16 19:53
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Chip] Interesting chips, interesting engineer souls
- Serial communication
- TMS320C6678DSP SRIO channel and frequency settings
- Development troubles, what to do when you encounter bad teammates
- Should 5G be blamed for cheating in the college entrance examination?
- How to use DRV8703-Q1
- Installation and use of saleae logic analyzer
- Generate sawtooth wave
- With the 5G wave, it’s time to upgrade RF filters!
- May Day holiday---spring cleaning