O Introduction
With the progress of science and technology and the development of social economy, it has become an inevitable trend for electronic password locks to replace traditional mechanical locks. In the past, the password lock system based on single-chip microcomputer directly stored the compiled password program in the on-chip EPROM, but it was not easy to modify the password; if the password modification function was to be completed, it was mostly implemented using an off-chip serial E2PROM. This paper studies and designs an infrared remote-controlled electronic password lock based on a single-chip microcomputer. It not only has the characteristics of intelligent control of locking, unlocking, and alarming of ordinary password locks, but also can realize the function of arbitrary modification of 8-bit passwords without expanding E2PROM, saving hardware resources and reducing the system size. This is an innovation of this design. In addition, the feature of remote unlocking is added. Therefore, the system is not only low-cost and highly confidential, but also more suitable for special occasions that normal human bodies should not approach, such as high radiation areas and high infection areas.
1 System Hardware Design
1.1 Overall system design
The system is mainly composed of two parts: infrared transmitting module and local processing receiving module. The overall design block diagram of the system is shown in Figure 1. The core of the transmitting module and the local processing receiving module are AT89C2051 and AT89S52 microcontrollers respectively. The infrared signal is sent and received through the serial port. The serial port working mode and communication baud rate settings of the two parts are the same.
The AT89C2051 microcontroller is a simplified version of the AT89C51, with only 20 pins and a small size. It has a wide voltage operating range of 2.7 to 6 V and has low-power idle and power-down modes. This microcontroller meets the requirements of this system for low-voltage power supply, low power consumption, and easy portability.
The AT89S52 single-chip microcomputer is used in the receiving module of this machine. The single-chip microcomputer has 3 timers. When setting the password and unlocking the door with a key, the function of automatic reset when the key interval exceeds 3s is designed, which is realized by timer T0 and T1 respectively; timer T2 sets the baud rate of serial communication.
1.2 Design of infrared emission module
The infrared transmitter module is just a handheld remote control, which consists of AT89C2051 single chip microcomputer, keyboard circuit, key K and infrared light emitting diode. The schematic diagram of the transmitter circuit is shown in Figure 2.
The password set in the transmitter module must be the same as that in the receiver module of this machine (see Section 2.2.1 for password setting methods). The set password is saved in the 31H~38H unit of the RAM memory. In standby mode, the system works in idle mode. When the key K is pressed, the system is powered on and sends password signals in sequence. The advantage of this is that the password can not only be changed arbitrarily with the host, but also can be unlocked by pressing only one key when unlocking by remote control, which is convenient for users.
1.3 Design of the receiving circuit of this machine
The control core of the machine's processing receiving circuit is the AT89S52 single-chip microcomputer. The external keyboard circuit, infrared receiving circuit , unlocking circuit, alarm circuit and key indication circuit, etc., the circuit schematic diagram is shown in Figure 3.
[page]
1.3.1 Design of infrared receiving circuit
The infrared receiving circuit uses an integrated infrared receiving head TL1838 to receive infrared signals. TL1838 integrates infrared reception and amplification. It can complete all the work from infrared reception to output compatible with TTL level without any external components, and its size is the same as that of ordinary plastic-encapsulated triodes. The output waveform of TL1838 is shown in Figure 4. When receiving an infrared signal within the frequency band, TL1838 will output a low level, otherwise the data is high level, thereby demodulating the "intermittent" infrared signal into the original continuous square wave signal.
1.3.2 Design of alarm circuit
The alarm circuit uses a buzzer to simulate the alarm. The buzzer is connected to the CPU pin P2.1, and the current is amplified by the NPN transistor. The frequency and buzzing time of the buzzer are controlled by the single-chip microcomputer. When the wrong password is entered to unlock, the high level output from the P2.1 port makes the NPN transistor 9014 conduct, and the two ends of the buzzer are powered, and the buzzer emits a 3 s alarm sound. When the password error occurs three times in a row, the system will alarm for a long time, which effectively plays an anti-theft role.
1.3.3 Design of power supply circuit
The power supply uses the LM7805 chip to provide a 5 V voltage for the microcontroller after voltage stabilization. The circuit is shown in Figure 5. It mainly uses household AC power, and a 9 V battery is used as a backup power supply. The advantage of this is that even if the power is off, the lock will not be unable to be opened.
1.3.4 Design of other peripheral circuits
Since the AT89S52 microcontroller has 4 parallel input and output ports and sufficient hardware resources, the keyboard circuit uses a relatively simple independent key. A relay is used in the circuit to control a green LED to replace the specific lock. When the password is correct, the lock is unlocked for 5 seconds and then automatically locked. A red LED is connected to the P2.0 port to remind the user whether the key is pressed by turning it on and off. This not only reminds the user ingeniously but also effectively protects the password.
2 System Software Design and Implementation
The design of the software part is based on assembly language, adopting modular design ideas, with the main program as the core and multiple functional module subroutines. The main program mainly plays a guiding and decision-making function, deciding what the system should do and when. The various functions of the system are mainly realized by calling specific subroutines.
2.1 Design of infrared emission module program
The encoding and modulation of the transmitting module is realized by software programming. When the key K is pressed, the password signal is sent to the data buffer SBUF in turn, and then the binary signal is modulated into an intermittent pulse train signal with a frequency of 38.5 kHz by using the method of "0" level modulation and "1" level non-modulation, and then output through the P3.0 port to drive the infrared light emitting diode, and finally send out the infrared remote control signal with infrared light of a wavelength of 940 nm. The infrared transmitting module program flow chart is shown in Figure 6.
The realization of 38.5 kHz modulated wave is based on the strict instruction cycle of assembly language. The low level and high level last for 13 machine cycles. The clock crystal oscillator used here is 12 MHz, so the precise frequency of the modulated wave generated is 38.46 kHz.
2.2 Design of the receiving and processing module program of this machine
[page]
The machine processing part can realize all functions such as password setting and modification, machine key unlocking, key prompt, password error alarm, overtime prompt, remote unlocking and automatic reset after more than 3 seconds between key presses. The main program flow chart of the machine processing is shown in Figure 7.
2.2.1 Design of password setting subroutine
The system can only set or modify the password when it is internally powered on and reset. When the system is reset, it enters the state of waiting for the user to press a key to set a new password. The 8-digit password entered by the user is saved in the 41H~48H units of the RAM storage unit in sequence. When the 8-digit password is set, the buzzer sounds for 1 s to indicate that the password has been successfully set. When the key is pressed to unlock, the entered password is compared with the numbers in the 41H~48H units in the RAM memory in sequence. As long as there is 1 bit that is different, the door lock cannot be opened and an alarm signal is issued.
2.2.2 Determination and reset of key interval timeout
The previous article mentioned that there is an automatic reset function when the key interval exceeds 3 s. Timers T0 and T1 are used to achieve this when setting the password and key unlocking. Both timers are set to 50 ms timer interrupts, and the time for 60 consecutive interrupts is 3 s. When a key is actually pressed and popped up, the corresponding timer interrupt is turned on and allowed to count. If the timer interrupt has occurred less than 60 times when the next key is pressed, the timer stops counting and resets the initial count value and the number of timer interrupts; if the timer has been interrupted 60 times before the next key is pressed, it means that 3 s have expired, and the system automatically performs a software reset. The reset program code for the key interval timeout when setting the password is as follows:
After the above program executes the RETI instruction, the PC pointer points to 0000H, and the program starts executing from address 0000H, which means that software reset is achieved.
When the keyboard is unlocked, if the interval between key presses exceeds 3 seconds, the program "reset" is not executed from address 0000H, but returns to the instruction after the "password setting end prompt tone" to start execution. The address of this instruction is obtained by using the single-step execution method: 0FC00H.
3 Conclusion
The highlight of this design is that it realizes the function of modifying passwords at will without expanding any E2PROM, and uses software reset to cancel invalid keys. The accuracy and security of the system are verified by testing various aspects such as setting passwords, keyboard unlocking, and infrared remote unlocking. The experiment proves that the system is low in cost and high in reliability, and is worthy of promotion and application.
Previous article:Technology Life: Overview of Supermarket Electronic Burglar Alarm System
Next article:Design of multifunctional electronic password lock based on AT89S51
- Popular Resources
- Popular amplifiers
- Mir T527 series core board, high-performance vehicle video surveillance, departmental standard all-in-one solution
- Akamai Expands Control Over Media Platforms with New Video Workflow Capabilities
- Tsinghua Unigroup launches the world's first open architecture security chip E450R, which has obtained the National Security Level 2 Certification
- Pickering exhibits a variety of modular signal switches and simulation solutions at the Defense Electronics Show
- Parker Hannifin Launches Service Master COMPACT Measuring Device for Field Monitoring and Diagnostics
- Connection and distance: A new trend in security cameras - Wi-Fi HaLow brings longer transmission distance and lower power consumption
- Smartway made a strong appearance at the 2023 CPSE Expo with a number of blockbuster products
- Dual-wheel drive, Intellifusion launches 12TOPS edge vision SoC
- Toyota receives Japanese administrative guidance due to information leakage case involving 2.41 million pieces of user data
- 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
- Share some information on time-of-flight ranging and imaging
- The impedance matching problem is shown in the figure
- Change C++ language to C in seven steps
- Add several bit manipulation functions to C language
- IMX6 development board Qt Creator directly compiles ARM architecture programs
- What is the principle behind this?
- Sell yourself, sell yourself
- ICE40LP1K CDONE pin is always low
- Is there a company where you can have breakfast until 10 o'clock, take a nap until 2 o'clock, and receive 18 months' salary per year?
- [Automatic clock-in and walking timing system based on face recognition] Maixbit/MaixPy pitfall! The audio playback function blocks the call