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.
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
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Today is Arbor Day, happy holiday~~
- Learn electronics and Arduino from scratch: A beginner's guide to developing boards
- [NUCLEO-L452RE Review] +2.2-inch TFT display driver display
- [GD32L233C-START Review] 14. CAU encryption algorithm AES
- Setting the switching frequency of the switching power supply chip LTM4613
- Does the power layer of a four-layer board need to be made into a complete plane?
- [Register to enjoy gifts] element16 sincerely invites you to visit the 2019 Munich Shanghai Electronics Show
- E104-BT05 Test
- I heard that every type of software has a chain of contempt...
- [Help] TD4.6.6-64bit cannot use the ChipWatcher (logic analyzer) function