- Home >> News >> Blog articles >> Internet of things
Electronic lock solution design and development
With the improvement of people's quality of life, science and technology are also advancing rapidly, but high-tech thieves also appear in our harmonious society, which makes how to achieve safe and effective anti-theft has attracted more and more attention. Due to its structural limitations, the safety of traditional mechanical locks cannot be greatly effectively improved, and incidents of being picked are not uncommon. However, electronic locks are welcomed by users because of their strong confidentiality, good flexibility of use, and high safety factor. . Various electronic locks have appeared on the market now, including voice locks, fingerprint locks, computer induction locks, and video alarm locks. After the appearance of these locks, many thieves were successfully kept out, but there are still a small number of high-intelligence criminals who still ignore their existence. The main reason is that the state requires that electronic locks must have a device that can be opened by mechanical means. As a result, the electronic lock cannot reflect the advantages of anti-technical opening. This design idea not only improves the anti-technical opening performance of the electronic lock part, but also Improved the performance of the anti-technical opening of the mechanical part.
1. The overall design scheme of the electronic lock
1.1 The structure of the electronic lock
The general structure of the electronic lock is shown in Figure 1. The control part of the electronic lock is composed of units such as input, storage, coding, identification, anti-interference, drive, display and alarm. Among them, the coding and identification circuit is the core of the whole control part. The power supply is essential for both the electronic lock control part and the execution part.
The actuator of the electronic lock generally uses an electromagnet or a micro motor to drive the lock body.
1.2 Design of electronic lock
The electronic combination lock uses a single-chip microcomputer as the main control core. The special function of the single-chip microcomputer (AT89S51) greatly enhances the security performance of the electronic combination lock, so that it can effectively prevent the possibility of multiple attempts to test the password. With the further development of single-chip microcomputer and other smart chips, the anti-theft lock will be intelligent, which will greatly improve the security performance of the lock. This design realizes the prompt function of one-time password input. If the password is incorrectly input, a "beep" alarm will sound to alert others. At the same time, peripheral devices can be added to realize remote alarm (for example, adding relays and other devices can be connected to the owner's phone, so that the owner can know that someone is operating illegally at home and call the police in time). If the password is entered correctly, a "ding dong" doorbell will sound. The single-chip microcomputer used in this system has powerful functions, which can realize intelligent control to complete the input, judgment and comparison of passwords, so as to perform corresponding unlocking display or alarm functions.
2.The development process of electronic locks
2.1 Hardware Design
This design is composed of single-chip microcomputer (AT89S51) part, 4×4 determinant keyboard part, seven-segment digital tube part, alarm part, motor driver chip, and motor 6 parts.
2.1.1 The main control device of the single-chip microcomputer is a single-chip microcomputer. AT89S51 is a low-power, high-performance CMOS 8-bit single-chip microcomputer. The chip contains a 4k-byte programmable system Flash read-only program memory. Produced by non-volatile storage technology, compatible with standard 8051 instruction system and pins, it can be programmed by both in-circuit programming (ISP) and traditional methods.
2.1.2 Selection of components (chips):
(1) This design uses a 4×4 determinant keyboard with a total of 10 number keys and 6 function keys. Use 4×4 to form 0~9 number keys, confirmation key F and modification key C, and 10 number keys are used to input passwords , and the other 6 function keys are: A, B, C, D, E, F. Among them, the function of the C key is to clear the previously entered data and re-enter when the input password is wrong. The function of the F key is to confirm the entered password.
(2) The digital tube uses a common cathode 4-in-1 digital tube SR420561K.
(3) The most common choice of motor drive chip is L298N in 15-pin Multiwatt package. (4) The interface of the ISP downloader is designed in the circuit, and the ISP-USB download line is selected.
(5) The motor used in the electronic lock needs to be small in size, high in efficiency, and large in starting torque, and the motor in the tape recorder meets this characteristic. The final selected motor is the tape recorder motor EG-530AD-6B. The motor has a working voltage of 6V, a speed of 2400 rpm, and a direction of CCW (counterclockwise). (6) Here transmission parts select plastic gear for use, determine transmission ratio, directly select from the market.
(7) There are no special requirements for the structure and material of the electronic lock body, dead bolt and ordinary pin lock, so these components can be directly used for the ordinary pin lock that has been transformed.
2.1.3 Hardware connection on the system board:
(1) Connect the 4 horizontal lines and 4 vertical lines of the 4×4 determinant keyboard to P3.0-P3.3 and P3.4-P3.7 respectively to complete the input of the password.
(2) Connect P0.0 in the "Single Chip Microcomputer System" area to the alarm with a wire, which is used to prompt the correct or wrong password input and make a corresponding sound.
(3) Connect P1.0-P1.7 in the "Single Chip Microcomputer System" area to the other end of the digital tube display with wires to realize the display of the digital tube.
(4) Connect P2.0-P2.7 in the area of "Single-chip Microcomputer System" to one end of the triode with wires and amplify the input to the digital tube display through the triode. Complete the display of the digital tube.
(5) Connect P0.1-P0.3 in the "Single Chip Microcomputer System" area to the L298N chip with wires to realize the control of unlocking.
2.2 Software Design
This design is a microcontroller control scheme based on AT89S51. Using the flexible programming design of the single-chip microcomputer, rich I/O ports, and the accuracy of its control, it can not only realize the basic combination lock function, but also add sound and light prompts and even add remote control functions. The content of the design program is: ① password setting, the password is fixed in the program memory ROM in this program, and the password is 6 digits. ②Password input problem: According to the password input designed in advance, press the confirmation key after inputting to execute the corresponding function. The system source program is written in C language.
2.2.1 Keyboard input part: The keyboard in this system adopts 4×4 determinant keyboard. The task of the keyboard processing program is to determine whether a key is pressed, to judge which key is pressed, and what the function of the key is; to eliminate the vibration of the key when it is closed or disconnected. Among the two parallel ports, one outputs the scan code, which makes the keys dynamically grounded line by line, and the other parallel port inputs the state of the key, and the key code is formed by the line scan value and the feedback signal to identify the key. Function.
2.2.2 Digital display part: This system uses a display circuit composed of 8-digit digital tubes as a prompt message. During initialization, "P" is displayed, and then enter the maximum 6-digit password. After the password is entered, press Confirm key "F" to compare the passwords. When the input password is correct, the prompt information of "1HELLO" will be displayed on the digital tube, and the prompt information of "2ERROR" will be displayed on the digital tube when the input password is wrong. During the process of entering the password, only one "8." will be displayed on the display for each password input from right to left. When the input password exceeds 6 digits, an alarm message will be given. During the password input process, if you make a mistake, you can use the "C" key to delete the wrong number just entered. During the process of entering the password, the entered password can be modified at any time.
2.2.3 Buzzer sound prompt part: This system uses P0.0 as the interface of the buzzer alarm, and compares the input password with the set password. If the password is correct, the buzzer will emit a "ding dong" sound ; If the password is incorrect, the buzzer will send out a “beep, beep” alarm sound.
2.2.4 Motor drive part: This system connects P0.1-P0.3 to the motor drive chip, drives the motor to rotate through the program, and the motor rotates when the password is correct.
3. Electronic lock function test and expansion improvement
3.1 Electronic lock function test
Set an initial password 123456 according to the programming, and use a 4×4 determinant keyboard to realize the input function of the password, as shown in Figure 4. When initializing, the display tube displays "P", and when the password is entered, the display tube only displays "8." After entering the password, press the F key to confirm. When the password is correct, the digital tube displays "1HELLO" and at the same time emits a "ding-dong" sound. And drive motor to start to rotate, can realize unlocking at this moment; If the password is not entered correctly, "2ERROR" will be displayed as a prompt message, and an alarm sound of "beep, beep" will be issued at the same time. During the password input process, the C key can be used to modify the input password. After unlocking, you can press the D key to set a new password. You can use the B key as a switch key to switch the power supply. E key to return to the previous page. According to the above steps and operation test, the system runs normally and the basic functions can be realized.
3.2 Electronic lock expansion and improvement
From the day when the electronic lock was invented, designers have continuously expanded its functions, making the simple electronic lock evolve into a multi-functional electronic lock, and then developed an intelligent electronic lock-entry control system and identification system. A typical example of an access control system is a card reading system. A card reader replaces a mechanical key with a type of plastic card similar to a credit card. The face of the reader includes a narrow slot into which cards with different code numbers can be inserted. Card readers are connected to a central control computer. The card reading system can be programmed to allow everyone to enter the designated room within the specified time, realizing the so-called multi-level access control in time. The system can print out a list of personnel entering and leaving within a specified time. Another important function of card reading is that the same card cannot be used by two people successively. If the card is recorded "IN" twice, the system will send out an alarm. When the encoded card is lost or stolen, or when a person's access authority has changed or ended, the card controller can be reprogrammed to make the card invalid immediately. Due to the development of human physiological feature detection technology, the entrance control system has been developed into a personnel identification system. It uses computer recognition pattern technology to verify human physiological characteristics, such as fingerprints, palmprints, hand shapes, voiceprints, retinal images and signatures, etc., and its authenticity has been generally accepted by people because physiological characteristics are difficult to imitate or be transform. The best way to identify and verify is to use a combination of human physiological characteristics and cards, passwords, and identification numbers to form a highly secure access control system - an intelligent electronic lock.
It can also be improved in the following aspects: the door will automatically lock whenever the inner door handle is used, and the safety door handle will prevent any illegal entry and will automatically lock when it detects that the door is closed. When the door lock is low on power, an alarm will sound and a warning will be displayed on the LED screen. If the battery power is completely exhausted, a 9 V standard battery can also be easily used as an emergency power supply for the door lock.
4. Design and implementation of network fingerprint electronic lock based on single chip microcomputer
With the continuous advancement of science and technology, electronic locks have begun to enter everyone's life. At present, electronic locks are developing rapidly and have gradually replaced traditional door locks. They are widely used in residential areas, enterprises, public facilities and family environments. The emergence of electronic locks greatly facilitates people's lives, and the unlocking and locking of access control can be realized without taking out the key. With the development of technology, electronic locks not only make people very convenient but also more and more secure. Common electronic lock verification methods include password verification, RFID verification and fingerprint verification. These methods are very safe, and only people who meet their identities can Unlock the door.
The more popular electronic lock cylinders now adopt the following methods: First, the electromagnetic lock, through the strong suction generated when the current passes through the silicon steel sheet, tightly absorbs the adsorption iron plate to achieve the effect of locking the door. Second, push and pull the electromagnetic lock. After the electromagnetic coil is energized, it will generate magnetic force to attract the movable iron lock cylinder, so as to achieve the effect of locking and opening the door. Third, the geared motor lock, through the DC geared motor to rotate the gear, pushes out the lock head to achieve the effect of locking the door.
Although the electronic locks currently on the market have many advantages, they also have some defects: First, the price is relatively high. The price of fingerprint locks on the market is basically more than 500 yuan, which is still unacceptable to ordinary consumers. Secondly, the installation method is incompatible with the original lock, and the original door lock must be replaced, resulting in waste. Again, there is no network function, so when the lock needs to be unlocked temporarily, the user who holds the key must be present, or the password of the electronic lock must be announced, which is neither safe nor convenient.
In response to the above defects, I designed a network fingerprint electronic lock, which is compatible with the current popular door lock types, and realizes the electronic lock function without destroying the original door lock. The electronic lock can provide two verification methods: fingerprint verification and RFID verification, and has added a network function to provide users with a remote control function, and can also upload the use log of the electronic lock to improve security.
4.1 Hardware Design of Network Fingerprint Electronic Lock
(1) The overall framework of the electronic lock system: This electronic lock uses AVR single-chip microcomputer ATmega328P as the main control chip. This chip has the characteristics of high performance and low power consumption, is affordable, easy to develop, and is completely suitable for the functions of this electronic lock. The fingerprint module adopts the common FPM10A module on the market. This module uses serial port communication and can store 1000 fingerprint information. It has fast recognition speed, high precision and high cost performance. For cost considerations, the RC522 module is used for RFID identification. The RC522 is cheap and uses the SPI communication method to communicate with the main control module without occupying the serial port. The system uses W5100 module for network communication, which provides RJ-45 network interface and encapsulates TCP/IP protocol stack on-chip, which is very suitable for network development. In order to improve the user experience, the system also adds an LCD screen and function keys.
(2) Design of the electronic lock lock body: a MG996R metal steering gear is installed at the knob position of the door lock, and the steering gear head and the knob are fixed, and then the steering gear body and the bracket are fixed, so that the steering gear can be controlled Turn the knob to achieve the effect of locking the door. This design method still utilizes the structure of the original door lock, and there is no need to replace the door lock.
4.2 Software Design of Network Fingerprint Electronic Lock
(1) Network development: This electronic lock uses a network platform to realize remote control and upload usage records. The main control chip communicates with the server through the network module, and reads the switch state of the remote server every 5 seconds. When the switch state is off, the program does not take any action. If the read switch state is on, the electronic lock will control The servo unlocks the door until it reads that the switch status is off. Every time fingerprint verification or RFID verification is used to unlock the lock, the door lock will automatically upload the user ID of this unlocking, that is, the fingerprint ID number or RFID tag ID number, and the platform will automatically record the date and time of this unlocking, and the record can be kept for 5 years , users can log in to the platform to obtain unlocking records.
(2) Other designs: In order to ensure the stability of the electronic lock, I added a watchdog timer to the program. The program will reset the watchdog timer every 8 seconds. If the timer is not reset on time, the program will A software reset is performed automatically. In order to prevent unexpected power outages, the system has an external power supply USB port, which can be powered by an external power supply during power outages to ensure the operation of the electronic lock.
Summarize
This design makes full use of the software and hardware resources of the AT89S51 single-chip microcomputer, introduces intelligent analysis functions, and improves the reliability and security of the system. In addition, the smart combination lock can form an intelligent distributed monitoring network with slight changes in software and hardware, and realize centralized monitoring and management within a certain range. application prospects.
The above are the details of the electronic lock solution introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. for you. If you have the development and design needs of smart password electronic locks, you can trust us. We have rich experience in custom development of electronic products. We can evaluate the development cycle and IC price as soon as possible, and can also calculate PCBA quotations. We are a number of chip agents at home and abroad: Songhan, Yingguang, Jieli, Ankai, Quanzhi, realtek, with MCU, voice IC, Bluetooth IC and module, wifi module. Our development capabilities cover PCB design, single-chip microcomputer development, Bluetooth technology development, software customization development, APP customization development, WeChat official account development and other hardware and software design. It can also undertake the research and development of smart electronic products, the design of household appliances, the development of beauty equipment, the development of Internet of Things applications, the design of smart home solutions, the development of TWS earphones, the development of Bluetooth earphone speakers, the development of children's toys, and the development of electronic education products.
Proposal recommendation
- TOP