Design of multifunctional electronic password lock system based on single chip microcomputer

Publisher:支持中文Latest update time:2022-04-23 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The password lock is based on the STC89C52 microcontroller, plus the necessary hardware parts, to achieve the setting, storage, and detection of passwords, thereby controlling the closing of the circuit to decide whether to unlock. The microcontroller converts the password entered by the user into a key code and compares it with the password stored in the 24C02 chip. The initial password set this time is a six-digit password, which allows more than 3 million passwords to be changed and selected, greatly increasing security. The optional password groups are arranged in succession. If the password is entered correctly, the relay is energized and the diode lights up, indicating that the password lock is open; if the password is entered incorrectly, the buzzer will send an alarm signal, and multiple errors will lock the keyboard until it is reset again.

The password lock is mainly composed of a single-chip microcomputer, a keyboard, external hardware and other devices. The matrix keyboard is used by the user to input and modify the password. This design uses a relay to replace the electromagnetic lock. In actual use, the relay can be used as an electromagnetic lock. Of course, the normally open contact of the relay can also be used to control the electromagnet to attract the coil. The single-chip microcomputer sends each unlocking operation and the driving current value of the electromagnetic actuator as status information to the chip of the single-chip microcomputer for processing. At the same time, the alarm information received from the infinite loop password recognition program is also sent to the intelligent alarm, so that the entire password lock can operate normally.

A DC voltage provided by the power supply circuit. Since the microcontroller needs an oscillation frequency to work, a crystal oscillator circuit is needed to provide a reference frequency. The reset circuit is a circuit that restores the circuit to the initial state. Here, the microcontroller and other components are kept in a specific state. When the power is supplied and the switch is pressed, it will reset. The keyboard interface circuit part provides the function of inputting the password. The unlocking circuit is as the name implies. When the password is entered correctly, the microcontroller will issue an unlocking request. The relay absorption and the diode light emission represent that the door is successfully opened. The alarm circuit is that when the password is entered incorrectly, the buzzer will sound an alarm.


The keyboard scanning module can display and modify the password. The password is input into the STC89C52 microcontroller through the keyboard scanning module, and the data we need is displayed through the LCD display. The system also has power-off storage, alarm and other functions. Power-off storage can increase the practicality of the password lock. In the alarm module, when the password we enter is correct, the password lock is unlocked and the light of the display module will light up. When the password we enter is wrong, the buzzer will sound an alarm to indicate the error.


1 Hardware Circuit Design

1.1 Main control module

The minimum system of the single-chip microcomputer includes the single-chip microcomputer, reset circuit, and clock circuit. The operating voltage range of the STC89C52 single-chip microcomputer is 4V-5.5V, so the single-chip microcomputer is usually given an external 5V DC power supply.

The minimum system of a single-chip microcomputer includes a single-chip microcomputer, a reset circuit, and a clock circuit. The minimum system of a single-chip microcomputer refers to the minimum configuration that can make the single-chip microcomputer work normally.


1.2 Keyboard Circuit

The keyboard needs to be connected to the CPU through an interface circuit. The CPU can use the query interface or interrupt method to determine whether the user is using the keyboard, and then determine the position of the key being used. Both the query method and the interrupt method must use the I/O port of the microcontroller. Because the matrix keyboard occupies fewer I/O ports than an independent keyboard, when multiple keys are needed, a matrix keyboard is generally used to achieve the function of multiple keys. This system uses a 4*4 matrix keyboard, and the keyboard connection method is shown in the figure:

1.3 LCD display circuit

LCD1602 is a character-type liquid crystal display, which is a dot-matrix liquid crystal display that is specially used to display letters, numbers, symbols, etc. The display capacity of LCD1602 is 16*2 characters (16 characters per row, two columns in total), the operating voltage of the LCD chip is between 4.5~5.5V, the operating current is 2.0mA (5.0V), and the optimal operating voltage of the module is 5.0V. In addition, it should be noted that in order for the LCD display to work normally, sufficient current must be provided. Therefore, in this design, in order to ensure the normal display of the LCD, a resistor is added to the data port to ensure smooth operation. This design uses a liquid crystal display LCD for display, and the specific connection method is shown in the figure.

1.4 Memory Chip Circuit

The operating voltage of AT24C02 is between 1.8V and 5.5V, and the input/output pins are compatible with 5V. AT24C02 is a two-wire serial interface that supports hardware write protection and has high protection. The number of read and write times is up to 1 million times, and the data can be stored for 100 years. E1~E3 are device address selection ports, and in this design, all are grounded. VCC can be connected to an operating voltage of 1.8V~6.0V, and a 5V voltage is connected here. VSS ground terminal, here is connected to the negative pole of the power supply. WP is a special write-protected port. When WP=1, it can only be read but not written. When WE=0, normal read and write functions can be performed. SCL is the serial clock input terminal, and SDA is the serial data and address line, which is used to transmit and receive data. It is a bidirectional port. P2.5 is the serial clock input line interface, and P2.6 is the data line interface. A0, A1, A2 are grounded, so when the microcontroller reads AT24C02, the device address is: 10100001B = 0A1H; when writing AT24C02, the device address is: 10100000B = 0A0H. WP = 0, allowing the microcontroller to perform read and write operations.


The AT24C02 series is a typical I2C serial bus EEPROM. This system uses this chip for data storage. The storage system connection is shown in the figure:

1.5 Alarm circuit

In this design, the alarm part consists of a buzzer and peripheral circuits. The alarm function is achieved by controlling the buzzer to sound. The buzzer is an electronic sounder powered by DC voltage. When a pulse signal is input to the P3.7 port, the buzzer will sound. The frequency of the buzzer sound can also be controlled by controlling the frequency of the input pulse. As shown in the figure.

1.6 Password lock circuit

In the single-chip computer password lock, when the correct password is entered, the lock will open. This design reduces the cost by not using an electromagnetic lock, but using a relay and a diode instead. When the password is entered correctly, the light comes on and the relay is energized, indicating that the password lock is open. Therefore, the circuit shown in the figure is used to replace the electromagnetic lock unlocking mechanism.

2 Software Programming

2.1 Main program flow chart

2.2 Keyboard Scanning Subroutine

2.3 Display module subroutine

 

2.4 Unlocking subroutine

2.5 Alarm subroutine

2.6 Power-off storage subroutine

 

In the design, we must first be familiar with and master the structure and working principle of the single-chip microcomputer, the interface technology of the single-chip microcomputer and the external characteristics and control methods of the related peripheral chips. The basic methods and techniques of circuit design of the core of the single-chip microcomputer are used to understand the calculation method of the circuit parameters. At the same time, learning to use the single-chip microcomputer is the best choice to understand the principles and structure of computers. In this design, all design requirements have been realized, and the password can be displayed in the form of "*" on the LCD display, and the functions of modifying the password and power-off storage are also realized. In the process of entering the password, the password can be cleared and reversed. If it is not operated for a long time, there will be a function to lock the password lock.

Reference address:Design of multifunctional electronic password lock system based on single chip microcomputer

Previous article:Design of intelligent community safety monitoring system based on single chip microcomputer
Next article:Design of a soccer-kicking smart car system based on single-chip microcomputer

Latest Microcontroller Articles
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号