51 single-chip computer password lock that can prevent multiple password attempts

Publisher:幸福时刻Latest update time:2011-12-28 Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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@R0A

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

JB00HAA6

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

DELAYMOV 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.


Keywords:MCU Reference address:51 single-chip computer password lock that can prevent multiple password attempts

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

Use of PIC microcontroller timer (16F877)
/*******************************************/  //Function: 60 countdown, buzzer and digital tube usage  //Development board: PIC16F877  /*******************************************/ include define uchar unsigned char define uint unsigned int void delay(uchar a,uchar x);  uchar table ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,
[Microcontroller]
Simple fingerprint lock source program based on AS608 and 51 single chip microcomputer
My roommate always forgets to bring his keys, so I made a simple fingerprint lock. Six people in the dormitory use it. This is the first time I upload it. It's quite crude. I wrote a very detailed comment (I think). If it can help you, it will be great. The microcontroller source program is as follows: #include r
[Microcontroller]
[Self-study 51 MCU] 10 -- PWM introduction, 51 MCU RAM area division
1. PWM Introduction PWM (Pulse Width Modulation), also known as pulse width modulation in Chinese, can use digital signals to achieve the effect of an analog signal. Pulse width modulation is to change the pulse width to achieve different effects. See Figure 10-1 for three groups of pulse signals. It is a waveform w
[Microcontroller]
[Self-study 51 MCU] 10 -- PWM introduction, 51 MCU RAM area division
Design of vehicle simulation driving dynamic data acquisition system based on HMR3000 and MCU
1 Introduction The vehicle driving simulation training system is a simulation system that uses modern technology to simulate real car driving. It can make car driving training safer, more economical, more efficient and more realistic. Compared with the existing vehicle driving simulation training system, the new veh
[Automotive Electronics]
Design of vehicle simulation driving dynamic data acquisition system based on HMR3000 and MCU
Serial port parameters of 51 single chip microcomputer
Commonly used modes are Mode 1 and Mode 3 1. Variable baud rate 2. The start bit is 1, the stop bit is 1, and the data bit is 8. 3. Mode 3 can select parity bit   ====================================================================== Recently, I happened to have a project using the serial port of 51, so I so
[Microcontroller]
TNY256 single chip switching power supply and its application
1 Performance characteristics of TNY256 ·Built-in automatic restart circuit, no external components required. Once output short circuit or control loop open circuit failure occurs, the duty cycle can be reduced to protect the chip. ·In the input DC high-voltage circuit, there is no need to use a clamp protection c
[Power Management]
Design of single chip microcomputer based on Proteus for embedded system
1 Overview With the rapid development of semiconductor technology and the application of mobile communication, network technology and multimedia technology in embedded system design, the development of single-chip microcomputers from 4-bit, 8-bit, 16-bit to 32-bit has always attracted great attention from electronic
[Microcontroller]
Design of single chip microcomputer based on Proteus for embedded system
Using VB to realize the communication between PC and multiple single-chip microcomputers
Preface In the data acquisition automation control system with PC as the control center, the single-chip microcomputer is usually required to collect data, and then transmit it to the PC by asynchronous serial communication. The PC performs timing control on the single-chip microcomputer, which requires mul
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号