1. Introduction
Many industries and places need password locks, but the passwords of ordinary password locks are easy to be cracked by multiple attempts. This paper presents a design method of password locks that can prevent multiple attempts, thus effectively overcoming the above shortcomings.
2 Hardware Circuit
Figure 1 shows a password lock circuit designed by the author. The password lock is designed mainly according to the following 10 user requirements:
(1) The password consists of 8 digits in total, and the value range of each digit is 1 to 8.
(2) Users can set and modify passwords by themselves.
(3) There will be sound and light prompts when pressing each password key.
(4) If the 8-digit unlocking password entered is not completely correct, an alarm will sound for 5 seconds to alert others.
(5) If the unlocking password is incorrectly entered three times, an alarm will sound for 10 minutes. During the alarm period, the password entered will be invalid to prevent thieves from trying the password multiple times.
(6) The lock can only be unlocked if the 8-digit unlocking password entered is completely correct, and there should be a 1-second prompt sound when unlocking.
(7) The electromagnetic coil of the electromagnetic lock must be driven by pulses, and each power-on time must not exceed 2 seconds to prevent burning.
(8) Only 8 password keys and 1 LED are allowed on the password keyboard. There is a backup battery in the lock . The password can only be set or modified when the internal power is reset. Therefore, the password cannot be modified or set by pressing the keys outside the door.
(9) After the password is set, there will be a 2-second prompt sound.
(10) The cost should be relatively low, and both the hardware and software should be as simple and reliable as possible, and easy to mass produce.
According to the overall requirements, the password lock circuit requires less than 15 I/O lines. If designed properly, the program will not exceed 200 instructions. Therefore, the high-quality and low-cost AT89C1051/2051 or GMS1051/2051 can be selected, and no external program memory, data memory and other expansion components are required.
In the circuit shown in Figure 1, port P1 is connected to 8 password keys AN1~AN8, unlocking pulse is output by P3.5, and alarm and prompt sound are output by P3.7. BL is a speaker for alarm and sound prompt , light-emitting tube D1 is used for alarm and prompt, and L is the electromagnetic coil of electromagnetic lock.
3. Software Design
Figure 2 shows the software flow chart of the single-chip computer password lock circuit. In the figure, AA1~AA8 and START, SET, SAVE are labels in the program, which are specially marked in the corresponding positions of the flow chart for the purpose of understanding the program. You can carefully refer to them when analyzing the program.
3.1 Allocation of storage units
The allocation scheme of RAM storage unit in the password lock is as follows:
31H~38H: Store the 8-digit set password in sequence, the first digit of the password is stored in the 31H unit;
R0: points to the password address;
R2: The number of digits of the password that has been entered;
R3: stores the difference between the allowed number of code errors 3 and the actual number of code errors;
R4 to R7: for delay;
00H: Error code flag.
Regarding the allocation of ROM storage units, since the program is relatively short and occupies relatively little storage space, the main program can be stored starting from unit 0030H (other addresses are also acceptable) if there is no special requirement.
3.2 Source Program
Below is the software source code of the electronic combination lock:
ORG 0000H
AJMP START
ORG 0030H
START:ACALL BP
MOVR0,#31H
MOV R2, #8
SET: MOV P1, #0FFH
MOV A,P1
CJNE A, #0FFH, L8
AJMP SET
L8: ACALL DELAY
CJNE A, #0FFH, SAVE
AJMP SET
SAVE: ACALL BP
MOV@R0A
INCR0
DJNZ R2,SET
MOV R5, #16
D2S: ACALL BP
DJNZ R5, D2S
MOVR0,#31H
MOV R3, #3
AA1: MOV R2, #8
AA2: MOV P1, #0FFH
MOV A,P1
CJNE A, #0FFH, L9
AJMP AA2
L9 ACALL DELAY
CJNE A, #0FFH, AA3
AJMP AA2
AA3: ACALL BP
CLR
SUBB A, @R0
INCR0
CJNE A, #00H, AA4
AJMP AA5
AA4: SETB 00H
AA5: DJNZ R2, AA2
JB00HAA6
CLR P3.5
L3 MOV R5,#8
ACALL BP
DJNZ R4, L3
MOV R3, #3
SETPB P3.5
AJMP AA1
AA6: DJNZ R3, AA7
MOV R5, #24
L5: MOV R4, #200
L4: ACALL BP
DJNZ R4, L4
DJNZ R5, L5
MOV R3, #3
AA7: MOV R5, #40
ACALL BP
DJNZ R5, AA7
AA8: CLR 00H
AJMP AA1
BP: CLR P3.7
MOV R7, #250
L2: MOV R6, #124
L1: DJNZ R6, L1
CPL P3.7
DJNZ R7, L2
SETPB P3.7
RET
DELAYMOV R7,#20
L7: MOV R6,#125
L6: DJNZ R6,L6
DJNZ R7,L7
RET
EN
4 Application Notes
If the keys AN1~AN7 represent numbers 1~7 respectively, and the key AN0 represents number 8. When no key is pressed, P1.0~P1.7 are all high level 1. If a key is pressed, the corresponding port line becomes low level 0. If the set password is 61234578, when the key AN6 is pressed, P1.6 becomes low level, and the rest of the ports of the P1 port are high level. At this time, the value read from the P1 port is 10111111, and the password value stored in the 31H unit is 10111111, which is BFH. By analogy, the password values stored in the 32H to 38H units are FDH, FBH, F7H, EFH, DFH, 7FH, FEH. To unlock, you must first press AN6 to make the first password value read from port P1 the same as the set value stored in unit 31H, and then press AN1, AN2, AN3, AN4, AN5, AN7, AN0 in sequence to unlock. Otherwise, the lock cannot be unlocked and the alarm will start.
Previous article:Comparison of Different Initializations between C8051F and 80C51 Series MCUs
Next article:51 Single-Chip Microcomputer Implementation of Electronic Speedometer
Recommended ReadingLatest update time:2024-11-17 00:25
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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
- MSP430F5438 clock system
- Repair of FOTILE embedded electric steamer, the water level sensor failed and the circuit was broken because of a small resistor
- ASM330LHHX automotive-grade 6-axis inertial module related information and driver
- Application design using the FRAM-based MCU MSP430FR57xx series
- EEWORLD University Hall----Live Replay: AVNET uses MPLAB? Ecosystem and Curiosity Nano Development Board to create an innovative development workflow
- BleuNRG-1 one master and multiple slaves master module search interval setting
- How to use iic to make LCD screen display
- Design of MSP430 and MMC/SD card interface
- An Engineer's Guide to Temperature Sensing
- N ways to program the development board