toothache

[Course Design] Smart home alarm system based on 51 microcontroller

 
Overview
First put a high-resolution picture
2.0 update instructions:
Corrected the LCD1602 fixing hole spacing to be 3.1MM, and the 1.0 version is 2.5MM, making it difficult for M3 screws to penetrate.
A diode was added to the TX-RX between the CH340 and the 51 microcontroller. It was not added in the 1.0 version, causing the CH340 to inject current, making the MCU unable to power off and always in a reset state, making it impossible to program the program.
Corrected the matrix keyboard printing. Version 1.0 will block the key value when pressing the matrix keyboard, making it easy to press the wrong key.
Correct printing errors, correct packaging errors, and fine-tune wiring.
 
 
The following portions in parentheses are excerpted from the lab report
( 1. Course design content
1. Design of smart home alarm system
2. Use the matrix keyboard and memory chip 24c02 to implement the password lock function, including entering the welcome interface with the correct password,
Modify the password, enter the wrong password three times and it will be locked for 15 seconds, and the password will be stored when the power is turned off;
3. Use temperature sensors and buzzers to implement over-temperature alarm functions, including temperature data reading and display, temperature
Threshold setting, over-temperature buzzer alarm;
4. Use LCD1602 to display temperature data in normal state. After activating the keyboard, enter the password lock and exit the password lock.
Return to normal state after
5. Trigger the alarm when someone approaches when unlocked
 
2. Purpose
1. Enhance the perceptual understanding of microcontrollers and deepen the theoretical understanding of microcontrollers;
2. Master the application of internal functional modules of microcontrollers, such as timers/counters, interrupts, memory, and I/O
, A/D conversion, etc.;
3. Understand and master the software and hardware design process and implementation methods of microcontroller application systems.
Design :
1. Research ideas on STC89C51 as the main control chip
The main functions of the STC89C51 microcontroller control system include: realizing password lock door, temperature monitoring,
Annual calendar display function, proximity alarm.
Main circuit: STC89C51, LCD1602 liquid crystal display module, DS18B20 temperature sensor module,
24c02 module, human body infrared sensing module, matrix keyboard module, through matrix keyboard input, realize various
The intelligent control of each module realizes part of the functions of the current smart home alarm system.
Design input part: This module mainly uses STC89C1 microcontroller P2 and P1 I/O to expand the independent keyboard.
and matrix keyboard to realize input to the machine and input to each module.
Design output part: This module mainly uses the LCD1602 liquid crystal display module to realize the microcontroller control process.
Process information is displayed.
Design control part: mainly composed of the external interrupt expansion circuit and I/O port expansion of the STC89C51 microcontroller
Circuit composition. )
 
Description of each module:
When welding the initial burning program, you need to initialize the password, so you need to uncomment the function to initialize the password in the program, and then burn it into the microcontroller, then comment out the function to initialize the password, and burn it into the microcontroller again. Normal use. Initialization function description: The function of the initialization function is to pre-write a set of passwords into the 24C02 chip to facilitate subsequent operations on the password. Since this function will set the password to a predetermined value every time it is used, this function only needs to be burned You can set the password in 24C02 once. If this function is enabled every time it is powered on, the password will be initialized every time it is powered on, causing the modified password to become invalid, that is, the modified password cannot be saved.
Matrix keyboard: The key values ​​of each key have been marked with printing silk. If you enter a wrong number, you can use the left shift key to return to the previous digit, and the right shift key to select the next digit (mainly used to modify the calendar and time). After inputting, press Confirm key to save.
Independent buttons: When a button is pressed, the indicator light of the corresponding function will light up. If you want to exit the function, just press it again. When one function is activated, press another button to enter another function.
Buzzer: used for alarm and simple instructions (different tones will sound when changing the password).
DS18B20: used to read the ambient temperature and set the maximum alarm temperature to 99.
Infrared receiving tube: used to receive the control of the infrared remote control. The remote control can completely control the system. (There is no requirement in this course, but having this is slightly more convenient than the keys on the keyboard)
Door lock indicator light: When it lights up, it means it is unlocked; when it turns off, it means it is locked.
24C02: Used to save password, temperature limit, date and time (since it is not a clock chip, it can only be saved when using the function to save time, that is, if the system time has passed five minutes, but the save is not performed according to the modified time, Then the time displayed the next time you power on will still be five minutes ago)
LCD1602: Displays all information, and there is a backlight adjustment resistor next to it. If you can't see clearly or there is no value, you need to manually adjust the backlight.
Reserved socket for pyroelectric module: You can use DuPont cable to plug into the pyroelectric human body sensing module, but the accuracy is not very good and it is easy to malfunction or cause random alarms.
CH340: Used for burning programs. When downloading programs, you need to power on the microcontroller again, that is, press the power button twice.
 
Function Description:
Unlock lock key : Enter the password. When the password is correct, the door lock indicator light turns on to indicate unlocking. If the password is entered again, the indicator light goes out, indicating that it is locked. If you enter the wrong password three times, the phone will be locked for 15 seconds, and the buzzer will briefly alarm. When the lock is completed, the buzzer will also briefly prompt, and then the password will be displayed.
Change password : Enter the 6-digit password. If it is correct, you will enter the new password input interface, and there will be a short buzzer prompt. The new password needs to be entered twice to complete the password change. If you enter an incorrect password three times, the phone will be locked for 15 seconds, and the buzzer will briefly alarm. When the phone is locked, the buzzer will also briefly prompt, and then it will display the old password.
Change temperature limit : Enter a two-digit target alarm temperature, up to 99. When the sensor temperature exceeds the set value, the buzzer will continue to alarm until the temperature is lower than the set temperature. At this time, the system response time will slow down because the buzzer sound takes up system resources, and because there is no remaining timer available, it will slightly affect the use of other functions.
Change the time : Enter the four-digit year, month, day, hour, and minute in sequence. Change to any position and press the confirmation key to save. The left shift cannot jump the separator symbol "-" . The data is stored in 24C02. Every time the password is changed, 24C02 will be written so that it can be read next time the power is turned on. The time cannot be saved in real time because it must be written to 24c02 every time it is saved. If written once every second, 24c02 will be easily scrapped.
When burning the program for the first time, you need to uncomment the initial password in lock.c in the source file, and then comment this part when burning the program for the second time. The main file name is ks.c and needs to be opened with keil4

 

Remote control instructions:
 
The number keys are completely corresponding, + is to unlock/lock , EQ is to change the password , 100+ is to change the temperature limit , 200+ is to change the time , - is to confirm , NEXT is to move left , PLAY is to move right
My remote control looks like this, but other remote controls may have different function buttons, but the number buttons are the same.
 
Reuse interface description:
P2^0, P2^1: In most cases, they are the unlocking function indicator light and the password change function indicator light, but they are also used to simulate IIC to read and write data to 24c02, so each time the data is saved or read, these two lights will flash briefly.
P3^0, P3^1: used as independent buttons, but used as serial ports when downloading programs.
P3^2: Usually used as an independent button, but also used as an external interrupt input, connected to the infrared receiving tube, used to receive data when the remote control issues instructions.
 
The reason why P3^4 is empty is that when I was debugging with the development board, I tried to move the key function of P3^2, and then the system got stuck, so I gave up using this IO port, but it seemed that it was my development board. The problem,
If you need to add any functions, this IO should be reserved, or you can try moving the P3^2 button yourself, but I won't move it.
 
The buttons are hand-soldered and will melt if you blow them with an air gun, so they are a little crooked. I originally had a bottle of board washing water, but it all evaporated, so I didn’t wash the board.
The onboard buttons need to be pressed for a longer time, about 0.5 seconds. If you press them too fast, the key value may not be scanned. The remote control responds relatively quickly. The LCD display update speed is slightly slower. It takes about half a second for the indicator light to be on before it is completely refreshed. This is the case with 89C51.
 
The following is the actual picture of 1.0: ( The reason for welding a direct diode is due to a design error in version 1.0, which caused current backflow. This has been corrected in version 2.0 )
Empty board↓
After welding↓
Video demonstration (the sensitivity of this human body sensing module is too poor and it always triggers by mistake)
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-08 12:41:41

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号