I. Introduction
With the improvement of people's living standards, the problem of how to achieve home anti-theft has become particularly prominent. Traditional mechanical locks are often pried open due to their simple structure. Electronic locks are popular among users due to their high confidentiality, good flexibility and high safety factor.
When designing this topic, two schemes were conceived: one is a single-chip control scheme with AT89s51 as the core; the other is a digital logic circuit control scheme composed of 74LS112 dual JK flip-flops. Considering that the principle of the digital circuit scheme is too simple and cannot meet the current safety requirements, this paper adopts the former scheme.
II. Scheme Demonstration and Comparison
Solution 1: Use digital circuit control. Its principle block diagram is shown in Figure 1-1.
Figure 2-1 Digital password lock circuit scheme
The advantage of using a digital password lock circuit is that the design is simple. The digital logic circuit composed of 74LS112 dual JK triggers is used as the core control of the password lock. There are 9 user input keys, of which only 4 are valid password keys, and the others are interference keys. If the interference key is pressed, the keyboard input circuit is automatically cleared, and the previously entered password is invalid and needs to be re-entered; if the user enters the password for more than 40 seconds (generally, the user will not exceed 40 seconds, and if the user finds it inconvenient, it can be modified), the circuit will alarm for 80 seconds. If the circuit alarms three times in a row, the circuit will lock the keyboard for 5 minutes to prevent illegal operations by others.
The circuit consists of two parts: the password lock circuit and the backup power supply (UPS). The UPS power supply is set to prevent the password lock circuit from failing due to power outages, saving users from trouble.
The password lock circuit includes: keyboard input, password modification, password detection, unlocking circuit, execution circuit, alarm circuit, and keyboard input times locking circuit.
Solution 2: A single-chip microcomputer control solution based on AT89S51 is adopted. By using the flexible programming design and rich IO ports of the single-chip microcomputer and its control accuracy, it can not only realize the basic password lock function, but also add power adjustment storage, sound and light prompts and even remote control functions. Its principle is shown in Figure 1-2.
By comparing the above two solutions, the single-chip solution has a larger room for maneuver. It can not only realize the required functions but also expand the functions to a great extent, and it can also easily upgrade the system, so we adopt the latter solution. [page]
3. Functional unit design of circuit
1. Unlocking mechanism
The signal is sent to the unlocking actuator through the single chip microcomputer, and the circuit drives the electromagnetic lock to close, thereby achieving the purpose of unlocking. The principle is shown in Figure 2-1.
Figure 3-1 Schematic diagram of the unlocking mechanism of the combination lock
When the password entered by the user is correct and is entered within the specified time (ordinary users are required to enter the correct password within 12 seconds, and administrators are required to enter the correct password within 5 seconds), the microcontroller will output a door opening signal, which will be sent to the unlocking drive circuit, and then drive the electromagnetic lock to achieve the purpose of opening the door. The actual circuit is shown in Figure 2-2.
The circuit consists of two stages: drive and unlock. The drive circuit is composed of D5, R1, and T10. T10 can be selected from ordinary low-power transistors such as 9014 and 9018 to meet the requirements. D5 is used as a reminder for unlocking; it is composed of D6, C24, and T11. D6 and C24 are used to eliminate the reverse high voltage and electromagnetic interference that may be generated by the electromagnetic lock. T11 can use a medium-power transistor such as 8050. The selection of the electromagnetic lock depends on the situation, but the suction force must be sufficient and have a certain margin.
In this design, based on the principle of saving materials, light-emitting diodes are temporarily used to replace electromagnetic locks. When the light-emitting diode is on, it means the lock is unlocked; when it is off, it means the lock is not unlocked.
2. Key circuit design
Since the design requires the use of a matrix keyboard, this design uses a row-column keyboard, which can also reduce the number of I/O lines occupied when the keyboard interfaces with the microcontroller. This method is usually used when there are many keys. The principle is shown in Figure 2-3.
Figure 3-3 Principle circuit diagram of determinant keyboard
Each intersection of a horizontal (row line) and a vertical line (column line) is not connected, but is connected by a key. Using this determinant matrix structure, only N row lines and M column lines are needed to form a keyboard with N×M keys.
In this single-chip computer system with a matrix keyboard and non-keyboard encoding, the keyboard processing program first executes the program segment that waits for a key to be pressed and confirms whether a key is pressed.
After confirming that a key has been pressed, the next step is to identify which key has been pressed. There are usually two methods for identifying keys: one is the commonly used line-by-line scanning query method; the other is the faster line reversal method.
Compare the 44 keyboard shown in Figure 2-3 to explain the working principle of line reversal.
First, determine whether a key is pressed on the keyboard. The MCU I/O port sends a full scan word to the keyboard, and then reads the row line status to judge. The method is: output the full scan word 00H to the row line, set all column lines to low level, and then read the column line level status into accumulator A. If a key is pressed, there will always be a row line level pulled to a low level so that the row line is not all 1.
Determining which key is pressed in the keyboard is done by setting the column lines to low level one by one and then checking the row input status. The method is: send low level to the column lines in turn, and then check the status of all row lines. If all are 1, the pressed key is not in this column; if not all are 1, the pressed key must be in this column and is the key at the intersection with the zero-level row line.
[page]
The key operation panel is shown in Figure 2-3. There are 10 numeric keys and 6 function keys. There are also 3 indicator lights and a buzzer on the keyboard.
Figure 3-4 Schematic diagram of key operation panel
The 10 numeric keys are used to enter the password, and the other 6 function keys are: CLR, EN, F1, F2, F3, F4. The function of the CLR key is to clear the previously entered data and re-enter the password when the password is entered incorrectly. The function of the EN key is to confirm the entered password. F1 is the management mode switch key. When the user accidentally enters the password incorrectly three times and the keyboard is locked, the management mode can be started at this time, and the administrator's password can be used to open the door. F2 is used to enter the password modification state. F3 is used to turn off the display, which can save power and prevent criminals from peeping at the password. F4 is used as a doorbell.
The three indicator lights L1, L2, and L3 above are used to indicate the status of the operation: L1 is the lock and input indicator status light, which is red under normal circumstances. When the keyboard is in action, the L1 light starts flashing. When the keyboard is in the locked state, the indicator light also displays red. L2 is the door opening indicator light. When the user enters the password correctly within the specified time, this light turns green, indicating that the door is open, otherwise it will not display. L3 is the administrator status indicator light. When F1 is pressed, the indicator light automatically lights up.
There is also a buzzer on the panel. One of its functions is to indicate whether the operation button is pressed successfully; another function is to sound the whistle as an alarm when the user enters the wrong password more than 3 times.
3. Display circuit design
The display circuit designed in this system is set up to give prompts to users. In order to save the port resources of the single-chip microcomputer, the display of this system adopts the serial display method, and only two serial ports of the single-chip microcomputer are used to complete the display function of the single-chip microcomputer. The circuit schematic diagram of the display circuit is shown in Figure 2-5.
Circuit setting: When the program detects that there is no key operation within 5 minutes, the display will be turned off. This function is implemented using a program. Once there is no key operation, a timer is started. When there is no key operation within 5 minutes, a program is started to turn off the display, which can achieve the purpose of saving energy.
The signal output from the microcontroller serial port is first sent to the shift register (74HC164) on the left. Due to the effect of the shift pulse, the data is shifted to the right to achieve the purpose of display. The shift register 74HC164 also serves as the driver of the digital tube. Plug 1 (header1) is connected to the power supply, and plug 2 (header2) is connected to the data and pulse output terminal. The function of the three rectifier tubes D1~D3 in the circuit is to reduce the working voltage of the digital tube and increase its service life.
Figure 3-5 Display schematic diagram
4. Design of AT24C02 power-off storage unit
The function of the power-off storage unit is to store the currently set unit price information when the power is disconnected. AT24C02 is a 2KB electrically erasable storage chip from ATMEL. It uses a two-wire serial bus to communicate with the microcontroller. The voltage can be as low as 2.5V, the rated current is 1mA, and the static current is 10Ua (5.5V). The data in the chip can be stored for more than 40 years in the case of power failure. It also uses an 8-pin DIP package, which is easy to use. Its circuit is shown in Figure 2-5.
Figure 3-7 Schematic diagram of power-off storage circuit
In the figure, R8 and R10 are pull-up resistors, which are used to reduce the static power consumption of AT24C02. Since the data line and address line of AT24C02 are multiplexed and the data is transmitted in serial port mode, only two lines SCL (shift pulse) and SDA (data/address) are used to transmit data with the microcontroller.
Every time the unit price is set, the system automatically calls the storage program to save the unit price information in the chip; when the system is powered on again, it automatically calls the memory read program to read the unit price and other information in the memory into the cache unit for use by the main program.
5. Power supply circuit design of password lock
In order to prevent power outages, this circuit has a backup UPS power supply, which includes a mains power supply circuit, a power outage detection circuit, an electronic switch switching circuit, a battery charging circuit and a battery. The power supply circuit diagram is shown in Figure 2-8.
Figure 3-8 Mains power supply circuit
The 220V mains power is stepped down into 12V AC power by a transformer, and then rectified by a rectifier bridge. The 7805 stabilizes the voltage to 5V and sends it to the electronic switching circuit. Since this circuit consumes less power, a small 10W transformer is selected.
[page]
R8, R9, R6, R7 and IC14 form a voltage comparator. Under normal circumstances, V+
The battery automatic charging circuit composed of T1 and T2 will automatically stop charging after the battery is fully charged. D1 is on to indicate charging, and D2 is a working indicator. R4, R5, and T1 form a voltage detection circuit. If the battery voltage is low, T1 and T2 are turned on to charge it. After the battery is fully charged, T1 and T2 are turned off to stop charging, and D1 is turned off. The function of C4 in the circuit is to filter out interference signals. The circuit diagram is shown in Figure 7:
Figure 3-10 Automatic battery charging circuit
6. Design overall block diagram
4. Programming
1. Module Introduction
The software design of the taxi meter pricing system is divided into the following modules:
(1) Main program module
The main program mainly completes initialization, sets interrupt vectors, checks whether keys are pressed, calls display, etc. The flow chart of the main program is shown below.
(2) Keyboard scanning and recognition subroutine
The keyboard adopts the query method and is placed in the main program. When no key is pressed, the microcontroller loops the main program. Once a key is pressed, it turns to the corresponding subroutine for processing and returns after the processing is completed. The program flow is shown in the figure.
(3) Power dispatch storage service program
When comparing passwords, you need to read the AT24C02 program, read the data stored in the chip into RAM, and then compare it with the entered password. When modifying the password, you need to save the entered password into AT24C02. The program flow is shown in the figure.
(4) Display subroutine
Since the data is displayed on a split screen, 5 display subroutines are used, namely: closed status display subroutine (DIS_A), unlocked status display subroutine (DIS_B), password input and modification status display subroutine (DIS_C), prompt subroutine after wrong password input (DIS_D). Locked status display subroutine after wrong password input more than 3 times within the specified time (DIS_E).
V. Conclusion
Because it uses a single-chip microcomputer as the core control element and a sensitive Hall switch device, this taxi meter has the characteristics of powerful functions, reliable performance, simple circuit and low cost. In addition, the optimized program makes it have a high level of intelligence.
However, during the design and debugging process, we also found some problems. For example, the price is limited in digits and the actual mileage may be very far, exceeding our display range.
The design of the meter is not user-friendly enough. For example, if it had a voice prompt function, it might be more practical.
Previous article:[Tips] How to deal with MCU cracking
Next article:Design of Universal Data Acquisition and Communication Instrument Based on W77E58 Single Chip Microcomputer
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Testing solutions for redundant link networks
- Key wireless technologies for 5G systems
- [NXP Rapid IoT Review] + Rapid IoT App Running Error
- How to Design an RF Power Amplifier: The Basics
- What is the principle of touch switch?
- What is jitter and phase noise?
- [Shanghai Hangxin ACM32F070 development board + touch function evaluation board evaluation] + OLED screen display driver
- Tailing Micro B91 Development Kit Burning Pitfalls Record
- Antai Testing - Sharing of Maintenance Experience of Tektronix AFG3021 Arbitrary Signal Generator
- Interrupt vectors for ARM (Cortex-M3)