fish001

RF key lock

 
Overview

Design of RF key password lock based on 51 single chip microcomputer
 
Topic analysis
         This design uses 51 single chip microcomputer as the main control chip. The hardware consists of power supply circuit, reset circuit and crystal oscillator to form the single chip microcomputer minimum system, which is the core part of the whole circuit. Combined with peripheral circuits, it forms an electronic password control system. If the user wants to unlock the lock, he must enter the correct password through the keyboard or use the IC card. If the password is entered incorrectly, the LCD prompt will be given. The password can be modified by the user himself, and the password can be modified after the lock is opened. After modifying the password, the password must be entered again for secondary confirmation to prevent misoperation. Considering the need to display Chinese characters, this system uses LCD12864 liquid crystal display. The memory 24C02 is used to store the password, and the alarm part uses a buzzer. When the IC card is detected, the buzzer will sound. Each key is given a specific function to control the switch and password change of the password lock, and send it to LCD12864 for display. The key scan is used to determine which key is pressed and feedback is given to the single chip microcomputer. The single chip microcomputer sends commands to other peripherals according to the corresponding function. 
 
Overall design scheme block diagram schematic diagram design description
    The hardware part of the system can be divided into the following circuit modules: 1. Crystal oscillator circuit; 2. Reset circuit; 3. Power supply circuit; 4. Storage circuit; 5. Display circuit; 6. Keyboard circuit; 7. Alarm circuit; 8. Unlocking circuit; 9. Radio frequency circuit.
1. Crystal oscillator circuit
    The minimum system of the single-chip microcomputer consists of a crystal oscillator circuit, a reset circuit and a power supply circuit. As the core part of the entire system, the execution of all instructions of the single-chip microcomputer is based on the clock frequency provided by the single-chip microcomputer crystal oscillator. As shown in the figure, the crystal oscillator circuit is
    a passive crystal oscillator that cannot oscillate by itself. It requires the oscillation circuit inside the chip to work together to oscillate. The role of C1 and C2 capacitors: help the crystal oscillator start oscillation and maintain the stability of the oscillation signal.
2. Reset circuit
    The setting and resetting of the single-chip microcomputer are both to initialize the circuit to a certain state. As shown in the figure,
    when the reset circuit is stable, the capacitor plays the role of isolating DC, and the reset button is in a pop-up state. There is no voltage difference in the circuit below, so the point below the button and the capacitor is equal to GND. This single chip microcomputer is reset at high level and works normally at low level.
3. Power supply circuit
    The power supply circuit provides power to the entire system. Since the relay in the design requires a 12V voltage, and the operating voltage of the 51 single chip microcomputer is 4.5V-5V, and the radio frequency IC card module operates at 3.3V, the power supply circuit uses a step-down device to reduce the voltage of the circuit. As shown in the figure, the power supply circuit
    D3 prevents the current from flowing back and damaging the power supply. U6 reduces the 12V voltage to 5V for the 51 single chip microcomputer. U7 reduces the 5V voltage to 3.3V for the radio frequency IC card module. LED2 is the power indicator. The capacitor filters the power supply circuit to make the output voltage basically stable.
4. Storage circuit
    The function of the storage unit is to store the currently collected information. JSM24C02 operates through the I2C bus interface and has a special write protection function. As shown in the figure, the storage circuit
    I2C bus is an open-drain parallel structure, so a pull-up resistor must be added externally. For the open-drain circuit, adding a pull-up resistor externally forms a line "and" relationship.
5. Display circuit
    In order to improve the display capability of the password lock, this design uses LCD12864 liquid crystal display, which can more intuitively understand the current status of the password access control system. As shown in the figure, the display circuit
    LCD 12864 liquid crystal screen has an operating voltage of +3.0V~+5.5V, and the logic level is compatible with the microcontroller, and can be directly connected to the IO port of the microcontroller. The interface between LCD12864 liquid crystal and microcontroller is shown in Figure 3. The 1st and 2nd pins of the LCD are the power supply terminals; the 19th and 20th pins are the backlight power supply terminals; the 3rd pin of the LCD is used to adjust the contrast of the LCD display. Here, a 10kΩ potentiometer is connected to the ground to achieve contrast adjustment; the 4th pin of the LCD RS is the write data/write command selection terminal to the LCD controller, which is connected to the P1.3 pin of the microcontroller; the 5th pin of the LCD R/W is the write data/write command selection terminal, which is the write data terminal when the level is high and the write command terminal when the level is low, and is connected to the P1.2 of the microcontroller; the 6th pin EN is connected to the P1.1 port of the microcontroller; the data interface of the LCD from pin 7 to pin 14 is connected to the P0 port of the microcontroller; the 17th pin of the LCD is connected to P1.0, and the high level cancels the reset; the 15th pin of the LCD is connected to the high and low levels to select the serial communication form.
6. Keyboard circuit
    The keyboard is a very important input device for the microcontroller and is the link to realize human-computer dialogue. When a key is pressed, a low level is assigned to the pin on one side, and all pins are scanned to see if they are the same as the initial assignment. If not, it is determined that the current key is pressed.
As shown in the figure
, the key circuit 7. The alarm circuit
    The microcontroller controls the transistor to drive the buzzer through the P1^6 pin. When the passwords entered three times are different from the set passwords or when the lock is opened or closed, the buzzer will work. As shown in the figure, the alarm circuit
    Because the output current of the 51 microcontroller IO port is relatively small, and driving the buzzer requires a relatively large current, the function of Q1 is to amplify the weak signal into an electrical signal with a larger amplitude value.
8. The unlocking circuit
    also controls the transistor of the unlocking circuit through the microcontroller to make the relay work. The function of the unlocking circuit is that when the correct password is entered, the password lock will be locked, that is, unlocked, and the wrong password will not be unlocked. As shown in the figure, the unlocking circuit
    LED1 is the unlocking indicator light, and R11 is the current limiting resistor to prevent LED1 from being burned out. The unidirectional conductivity of D2 is used to prevent the current from flowing back and causing damage to the circuit. The function of Q2 is to amplify the weak signal into an electrical signal with a larger amplitude value, and it is also used as a contactless switch to drive the relay to control the switch of the lock.
9. Radio frequency circuit
    RFID: (Radio Frequency Identification) wireless radio frequency technology. Simply put, there is no need to establish mechanical contact or optical connection between the identification system and the identification target, but a communication system is established using microwaves. The complete RFID system consists of three parts: a card reader, an electronic tag, and a data processing program. The working principle of RFID: When the electronic tag enters the range that the reader can read and write, the electronic tag can receive the radio frequency signal emitted by the reader, and send out its own information with the energy generated by the induced current. Or the tag actively sends out its own information. Next, the receiver decodes the received data and sends it to a higher-level application for processing. Use the 51 single-chip microcomputer to load the RFID-RC522 module to read the content of the IC card or write content to the IC card. Then, the data obtained by the 51 single-chip microcomputer is sent to the computer via USB for further processing.
PCB design instructions
Note: Try not to have sharp angles or right angles in the routing, try not to be parallel to the top-level routing and the bottom-level bus, but vertically, the power line should be thickened, and the crystal oscillator circuit should not be copper-coated.
Software Description
Code Block:

See project attachment /////////////////////////////////////////////////////////Function: card search////////////////////////////////////////////////////////void readCart(){ unsigned char status; status = PcdRequest(PICC_REQALL, g_ucTempbuf1);//*PICC_REQALL=0x52: search for all cards that meet the 14443A standard in the antenna area PICC_REQIDL=0x26: only search for cards that have not entered the sleep state //Card search failed if (status == MI_OK) { status = PcdAnticoll(g_ucTempbuf1); //Anti-collision processing, output card serial number, 4 bytes } if (status == MI_OK) { status = PcdSelect(g_ucTempbuf1); //Select the card and enter the card serial number, 4 bytes } if (status == MI_OK) { status = PcdAuthState(PICC_AUTHENT1A, 1, DefaultKey, g_ucTempbuf1);//Turn on the antenna feeb(); } if (status == MI_OK) { status = PcdRead(1, g_ucTempbuf2);//Read the card---data block 1 of the first sector } if(status == MI_OK) { g_ucTempbuf2[16]=0x11; CALL_isr_UART(); OnOrOff = 1; }}


Physical display instructionsPrecautionsThe
LCD12864
display has a positive and negative display direction. You can ask the merchant when buying it.
It is recommended to add a heat sink to the two step-down chips to prevent the problem from being too high and burning the capacitor of the circuit.
Demonstration video
RF IC card key password lock_bilibili_bilibili
other attachments upload
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-08 15:31:56

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

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号