- Home >> News >> Blog articles >> Internet of things
The hardware design of single-chip microcomputer for electronic password lock
At present, the application of RSA electronic encryption lock technology in foreign countries has been very mature, especially in the United States, Germany and other computer technology developed countries, its application has been quite common. The United States has applied this technology to public key encryption standards and electronic commerce. Electronic combination locks include graphic locks, combination locks, fingerprint locks, face recognition, etc. These security locks use different locking and unlocking modes, and most of them use the unlocking principles of capacitance, machine code, and thermal sensing, which have high security. , providing a strong guarantee for the security of network users' personal information and finances. However, there are still a small number of high-intelligence criminals who still ignore their existence. The main reason is that these encryption technologies are highly destructible under the existing lock-breaking technology, so that they cannot achieve Requirements for protection of greater secrecy.
At present, the unlocking and unlocking mode of the RSA electronic combination lock is basically consistent with the unlocking and unlocking mode of the RSA combination lock used in the United States, but the main hardware used is different. The STC89C52 microcontroller used in the electronic combination lock uses assembly language to process information internally. The requirements are low, which improves the feasibility of the wide application of electronic combination locks. In this design idea, the RSA key encryption technology is used. Since the RSA encryption technology is still an unbreakable encryption technology at present, the unbreakability of the combination lock is increased, and the security performance of the electronic combination lock is improved. Simple and cost-effective.
1. Electronic combination lock microcontroller system design
1.1 The internal pin original function and external realization of the single chip microcomputer
Single-chip microcomputer is a kind of integrated circuit chip, which adopts VLSI technology to combine central processing unit CPU with data processing capability, random access memory RAM, read-only memory ROM, various I/O ports and interrupt systems, timers/counters, etc. It also includes the function of displaying the driving circuit, sending data, receiving information, processing information and making external responses, so as to simulate a combination lock. There are four eight-bit parallel I/O ports inside: denoted as P0, P1, P2 and P3, each port is a quasi-bidirectional port, including a latch, an output driver and an input buffer.
Port P0 is mainly used for digital display. The P1 port is mainly used for external unlocking and locking and relative state display. The input and output circuit diagram is shown in Figure 1. The first bit (P2.1) of the P2 port is connected to the DIO end of the relay, and controls the high and low levels in the single-chip microcomputer to provide instructions for the P3 port to control the interrupt.
The P3 port is mainly the controller, the 0th bit of the port is connected to the TX end of the Bluetooth, which is the receiving end of the serial port of the microcontroller, and the first bit of the P3 port is connected to the RX end of the Bluetooth, which is the sending end of the serial port of the single-chip microcomputer. Button S4 is internally connected to the second bit of P3 port, which is external interrupt 0 (low potential), and button S5 is internally connected to the third bit of P3 port, which is internal interrupt 1 (high potential).
As a general I/O port, the P1 port is designed to control the rotation of the external lock head of the electronic combination lock. The operation of P1 can be operated by byte or by bit. After reset, the port latch is "1". For the port line used as input, the port latch of the corresponding bit cannot be written into "0". In Figure 1, P1.0~P1.3 are used as output lines, respectively connected to , lock body, lock handle, unlock status indicator light and lock status indicator light, P1.4~P1.7 are used as input lines, connected to four switches S0~S3. The subroutine in Figure 1 uses byte operation instructions to send the switch status to P1.0~P1.3 for display, S1 and S2 are closed, P1.0 and P1.2 are in the state of unlocking and unlocking indication respectively, and S3 and S4 are closed, and P1.1 and P1.1 are closed. P1.3 is in the locked and locked indication state respectively, if the status indicator light cannot indicate the state synchronously with the lock head and handle, it means that the electronic encryption lock is faulty and needs to be repaired.
1.2 Functions of MCU
1) Connection: Same as connecting the conversion module, the RX of the Bluetooth module is connected to the TX of the single-chip microcomputer, and the TX of the Bluetooth module is connected to the RX of the single-chip microcomputer. Here, the RX and TX pins of the single-chip microcomputer are respectively P3.0 RXD (serial input port) and P3.1 TXD (serial output port), and then record each other's IP addresses. When connecting the Bluetooth module and the single-chip microcomputer, it is also necessary to keep the crystal oscillator of the two the same, generally around 12MHZ, and the size of the crystal oscillator can be queried in the detailed data parameters when purchasing a certain platform.
2) Data transmission: There are 28 kinds of assembly language instructions for data transmission, and the following 8 kinds of mnemonics are used: MOV, MOVC, XCH, XCHD, SWAP, PUSH, POP, MOVX, and can also be used in C language code UART_DMA_Enable transmits information, and the electronic dongle mainly uses the sending method of UART_DMA_Enable calling dma (direct memory). The type of data transmission can be divided into internal RAM data transmission instructions and off-chip RAM data transmission instructions, on-chip RAM data transmission instructions can be divided into immediate type, direct type, register type and register indirect address type, immediate type data transmission The mnemonic MOV is generally used. What the electronic code lock uses is the immediate data type transfer instruction of the on-chip RAM.
The serial port of the 51 single-chip microcomputer is a full-duplex serial port, which can receive data while sending data. When the serial transmission is completed, the flag bit TI will be set to 1. Similarly, when the data is received, RI will also be set to 1. Regardless of whether RI or TI appears 1, as long as the serial port interrupt is open, the microcontroller will enter the serial port interrupt processing program. In the interrupt program, it is necessary to distinguish whether the research is the interrupt caused by sending or the interrupt caused by receiving, and then deal with them separately. If 1 is received, P10 will be set to high level, and if 0 is received, P1.0 will be set to low level. When it is at a high level, it is in an unlocked state, and the input and output circuits are shown in Figure 1 to complete the unlock request.
3) Receive information: To receive information, the code uses the program memory ROM to fetch data instructions. There are only two such instructions, and the data is read from the program memory ROM and sent to the accumulator. These two instructions are often used in table lookup operations, so they are also called lookup instructions. The internal mainly depends on P3.6/WR (external data memory write strobe) and P3.7/RD (external data memory read strobe) . The serial port receiving program is based on the serial port interrupt, each time the single-chip serial port receives a byte of data, an interrupt is generated, and then the data received by the serial port can be obtained by reading the register. However, in practical applications, basically there will be no single-byte reception. Generally, it is multi-byte communication based on a certain serial communication protocol. In 422 or 485 communication, there may also be a host (usually a computer) with multiple slaves (corresponding boards with single-chip microcomputers). This requires that the single-chip microcomputer can identify the communication protocol corresponding to its own board card in the serial port data sequence received continuously to perform control operations, and do not perform any operations if it does not meet the requirements. To put it simply, the single-chip microcomputer needs to find a few bytes of data that meet certain rules in a string of data to achieve a matching effect.
2. The principle and function of Bluetooth module
2.1 Function and function of Bluetooth module
The Bluetooth module refers to the basic circuit set of the chip integrated with the Bluetooth function, which is used for wireless network communication and can be roughly divided into three types: data transmission module, remote control module and data acquisition module. General modules have the attributes of semi-finished products, which are processed on the basis of chips, making subsequent applications more convenient. The electronic combination lock uses a semi-finished Bluetooth module. The bluetooth module of the electronic combination lock is equivalent to the unlocking device. It is a module used to store RSA encryption source code and decryption source code.
1) Connection: use the HC-05 Bluetooth module, connect to the computer through the USB-TTL adapter before connecting with the microcontroller, and debug through the serial port debugging assistant. Enter the command debugging mode, enter the AT command, and set the parameters of the module. Set the name of the Bluetooth, and use the command AT+name=”xxx” to set the name of the Bluetooth module to xxx, which is convenient for subsequent searches. Set the baud rate of the serial port in the automatic connection mode to 9600. In order to match the baud rate of the Bluetooth module, use the command AT+uart=9600,0,0 to set the baud rate to 9600, 1 stop bit, and no parity bit . If the Bluetooth module is a mobile phone, the Bluetooth function of the mobile phone can be directly used for Bluetooth connection, and the baud rate can be set in the Java code of the Bluetooth module.
2) Send information: After the pairing is completed, the IP addresses of both parties have been recorded between the devices, and the HandleMessage thread is triggered to transmit data by clicking the listView device, and the data stream is transmitted in the form of byte stream.
3) Receive data: automatically receive the data stream by triggering handler.sendMessage, and then convert the character form after receiving it in byte form to achieve the purpose of obtaining data.
2.2 Hardware function process
When starting to use the electronic combination lock, first initialize the Bluetooth module and the single-chip microcomputer, mainly to perform the restart operation. In the second step, you only need to press the request button on the Bluetooth module to request to request to regenerate the password key, which can be received by the single-chip computer and Information processing information, make instructions for generating passwords and saving passwords, the MCU display screen will prompt that the password setting is complete, the third step, use the Bluetooth module to send an unlock request message, the LCD screen will show that the unlocking is successful, and the unlocking status indicator light is on , the lock head rotates to achieve the purpose of unlocking. The process of unlocking and unlocking saves the process of manually entering the password, and uses a function to directly call the receiving information port internally.
epilogue
Electronic encryption lock chooses 51 single-chip microcomputer because of its simple instructions, simple peripheral circuit, convenient hardware design, simple I/O port operation, no direction register, abundant available resources, general design can meet the needs of electronic combination lock, and easy to learn It is easy to understand and convenient for the maintenance work of the electronic combination lock in the later stage. The Bluetooth module is cheap, easy to buy, rich in information and easy to obtain, easy to program, low in power, easy to use a low-power battery for long-term power supply in the event of a power outage, and uses Bluetooth communication, not limited by the Internet, even in the absence of It can also be used normally in the case of wireless network. Therefore, the electronic combination lock designed based on the 51 single-chip microcomputer module will be accepted by the public and widely used due to its characteristics of simple operation, high safety factor and low price.
The above is the development example of the electronic combination lock introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. for you. If you have the development needs of electronic combination lock control board solutions, you can trust us. We represent a variety of single-chip microcomputers, voice chips, dual-mode Bluetooth ICs, and wifi chips. Brands include Songhan MCU, Yingguang MCU, Jerry Bluetooth, Ankai Bluetooth, Allwinner, and Realtek. Our technical services include: PCB design, microcontroller development, Bluetooth solutions, software and hardware custom development, APP development, small program development, WeChat official account development, etc. It can also undertake the design of intelligent electronic products, the development of living appliances, the research and development of beauty equipment, the application of Internet of things platform, the smart home control system, the development of TWS earphones, Bluetooth earphone speakers, the development of children's educational toys, the design of electronic education products, etc.
Proposal recommendation
- TOP