ТЕЛЕКОММУНИКАЦИИ: СЕТИ И ТЕХНОЛОГИИ, АЛГЕБРАИЧЕСКОЕ КОДИРОВАНИЕ И БЕЗОПАСНОСТЬ ДАННЫХ
UDC 339.138
DESIGN OF SMART CODE LOCK
YU CHUYUE, XIA YIWEI, ZHAO DI, HU ZHIFENG
Belarusian State University of informatics and Radioelectronics, Republic of Belarus
Submitted 22 November 2021
Abstract. This design uses MCS-51 single-chip microcomputer and the corresponding interface
chip to complete the design of a smart password lock. The matrix key input module is used as the
input channel for passwords and related information, and the display screen LCD1602 is used to
display the prompt words through a stepping motor. The rotation of the door lock can be opened and
closed, and the buzzer and LED are used to realize the sound and light alarm when the password is
wrong. In addition, the uniqueness of this design is that the proximity switch is used to detect
whether the door is closed or not, which is more intelligent.
Keywords: Password lock, Stepper motor, Human machine interface, Proximity switch.
Introduction
The development of electronic technology, especially with the emergence of large-scale
integrated circuits, has brought fundamental changes to people's lives. In modern society, with the
general improvement of people's security awareness, code locks are not only used in daily life, but their
functions are also reflected in all aspects [1]. And this design uses MCS-51 series single-chip
microcomputer as the control core to realize the design function of smart code lock.
The main function of this product is to ensure the safety of the door. After the main program is
used to execute the initialization, the while statement is entered. When no key is pressed or the key is a
non-function key, 1602 displays a statement to prompt the user to select a function, and when there is a
function key After pressing the programming idea of selectively entering the subroutine, the following
operations are realized: manually set the password, manually modify the password, automatically open
the door after verifying the password, realize the waiting at a fixed time and intelligently identify
whether the door is closed, if it is not closed, it will be realized Automatically alarm and automatically
stop and wait. It has certain reference significance for the further design of various types of smart locks.
System composition
The intelligent password lock system consists of a single-chip microcomputer system module, a
keyboard input module, a display module, an alarm module, an EEPROM storage module, and an
unlocking module. The display module is LCD Lcd1602, which is used to display various prompts and
step instructions. The keyboard input module is used to operate the display content of the LCD. Different
keys have corresponding functions, which can realize the functions of setting passwords, changing
passwords, confirming current operations, deleting specific characters and verifying passwords [2]. The
stepper motor is mainly operated after verifying the correct password. Its main function is to control the
opening and closing of the door lock, which are respectively forward 360° unlocking and reverse 360°
unlocking. The function of the proximity switch LP-18Y8C is to be able to judge whether the door is
closed normally. The system structure diagram is shown in Fig. 1.
72
Fig. 1. System structure block diagram
The working principle of the system hardware module
The smart password lock is mainly connected with the AT89C52 chip and the liquid crystal
display, and is connected with the 4×4 matrix keyboard. The matrix keyboard has the function of
selection. The optional functions include but not limited to setting passwords, changing passwords,
typing and verifying passwords. AT24C02 chip is the core component of the data storage part.
When the password verification is successful, the single-chip microcomputer outputs the high and
low levels of the specific step sequence to the output interface part through the P port [3]. UIN2003 and
its peripheral circuits act as isolation and amplifying current, and the stepping motor is controlled by the
P port output voltage to achieve unlocking function. The matrix keyboard part is equipped with 15 keys
including number keys and function keys to control the display content, namely: number keys 0–9, set
password, delete, confirm, modify password, and enter password. The data access part stores the unlock
password when setting the password on the keyboard, and calls the password when the password is
entered to verify the entered password to confirm whether to unlock. The 24C02 chip is an EEPROM
device with IIC interface. The so-called EEPROM is electrically erasable programmable read-only
memory, which is a type of ROM. It is a read-only memory, that is, it can continue to store the program
when power is off, and at the same time it can be erased and rewritten under the action of higher than
normal voltage, which greatly facilitates the development of the single-chip microcomputer, and realizes
the power-down storage function and update password settings.
The working principle of the system software module
The software part is mainly composed of the following modules: keyboard scanning module,
liquid crystal display module, storage module, stepper motor rotation module, timing interrupt module,
alarm module, proximity switch module.
In the main program, the program cyclically executes the judgment keyboard scan. If no key is
pressed or the pressed key is a non-function key, the LCD will continue to display «select function:». If
it is detected that a key is pressed, the corresponding subroutine is executed. After the subroutine is
exited, the main program continues to be executed: the keyboard scanning program detects which key
is pressed, and then enters the corresponding judgment statement to execute according to the demand, it
can Set the password, you can also change the password, and update the changed password to the IIC;
the external interrupt service program is used for the timing opening after unlocking [4]. After the
unlocking is successful, a part of the time is reserved for the unlocker to enter, and then timing, timing
ends, the door Close again. The alarm module is used to control the sound and light alarm when the
password is detected incorrectly. The proximity switch module is used to judge whether the door is
closed or not. Because the proximity switch is an NPN Hall element, it only corresponds to two different
states when a fixed object is detected, so only the single-chip microcomputer needs to read the pin state
of the pin. However, if the pin status is high, it means that the door is not detected and an alarm is issued.
If the pin status is low, it means the door has been detected. The single-chip microcomputer controls the
stepper motor to turn the lock cylinder back to achieve intelligent lock closure [5].
73
Conclusion
In this work, the development of an electronic combination lock, designed to be installed on the
outer door of a residential building, was carried out. A feature of this lock is the presence of an audible
alarm that notifies the owner of an attempt to select a code.
In the course of the work, the analysis of the task was carried out, on the basis of which the
requirements for the final system were formulated. Based on the requirements, a structural diagram was
built. Based on the structural diagram, appropriate devices were selected to implement the functions
assigned to the system elements. Further, using the selected devices, a functional diagram was built. The
development was completed by drawing up a block diagram of the algorithm and writing the source
code of the program for the microcontroller.
Thus, during the implementation of this project, a digital password locking control system was
developed with a single-chip microcomputer as the core and password input through the panel keyboard.
This system includes a single-chip microcomputer system module, keyboard input module, display
module, alarm module, and so on.
References
1. Zhang Yigang. Newly edited MCS-51 Application Design. Harbin: Harbin Institute of Technology Press, 2003.
2. Lu Xiaoxuan // Journal of Qingdao University of Science and Technology. 2006. P. 268–271.
3. Li Xin // Microcomputer Information. 2006. P. 32–37.
4. Yang Meixian // Scientific Information. 2007. P. 35–39.
5. Zhang Youde, Zhao Zhiying, Tu Shiliang. Principle, Application and Experimental Design of Single Chip
Microcomputer. Shanghai: Fudan University Press, 2008.
74