Design and implementation of a simple infrared remote control password lock

Publisher:532829319hmkLatest update time:2010-09-29 Source: 现代电子技术 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

20d.jpg

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.

Reference address:Design and implementation of a simple infrared remote control password lock

Previous article:Technology Life: Overview of Supermarket Electronic Burglar Alarm System
Next article:Design of multifunctional electronic password lock based on AT89S51

Latest Security Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号