Small hands-on project: design of intelligent desk lamp controlled by 51 single chip (automatic induction dimming) circuit diagram, test diagram, full source code technical information

Function and Overview
This system is composed as shown in Figure 1, which is mainly composed of three parts:

  1. Sensor and signal processing part: Detects human body radiation infrared signal and light intensity signal and becomes a processable digital signal after processing
  2. A central processing unit composed of 80C51: processing signals and issuing control commands
  3. Reminder circuit and light control circuit: give reminder signal and control light according to the command given by 80C51. The
    whole system works under the control of 80C51. The working process is: when the ambient light is relatively strong, the resistance of the photoresistor is relatively small, the signal processing circuit detects a low-level signal, the pyroelectric infrared sensor is prohibited from working, and the 80C51 processing process is omitted. When the ambient light is relatively weak, the resistance of the photoresistor becomes larger, and the signal processing circuit receives a high level, thereby starting the work of the pyroelectric infrared sensor. The pyroelectric infrared sensor 1 detects a relatively long distance. When the human body enters the control range of the sensor 1 and the light intensity is weak, the signal detection circuit processes the signal and sends an interrupt to the microcontroller. The 80C51 starts the light control circuit to make The light slowly turned on. When the ambient light is weaker than the calibration, and the human body is too close to the desktop, the pyroelectric infrared sensor 2 detects the signal, and the signal processing circuit simultaneously sends a signal to the 80C51 and the 80C51 processes within the control range of the pyroelectric infrared sensor 1. According to the priority order, the signal shields the pyroelectric infrared sensor 1 signal, activates the delay circuit, and sends an alarm to let people leave. If it does not leave the desktop within the set time, the light control circuit is activated to slowly extinguish the light. . When the human body leaves the control range of the pyroelectric infrared sensor 2 and is within the control range of the pyroelectric infrared sensor 1, the light slowly turns on again.

Design information
Insert picture description here
Insert picture description here
Circuit schematic diagram
Insert picture description here
3. Test result:
The main design idea of ​​this system comes from life. The table lamp is a necessity of life for ordinary families, but it often causes huge energy waste due to frequent forgetting to turn off the lamp. With so many lamps in the world, it is estimated that the energy consumption is considerable. The other is as a necessity, of course, to make life more convenient, save the trouble of turning on the lights in the dark, and correct the sitting posture. The system has carried out physical experiments in the laboratory. The distance of the pyroelectric infrared detector 1 is about 4m (distance is adjustable), mainly because the door is generally away from the desk; so that people start when they reach the door in the dark, saving the trouble of turning on the light, The user can adjust the distance according to his actual situation. The distance of the pyroelectric infrared detector 1 is about 10cm (the distance is adjustable). The main consideration is that when learning, sometimes the sitting posture is not correct, causing the body to be too close to the desktop, which is easy to cause myopia. If it does not leave within the set time, it will be extinguished forcibly. Sometimes people are tired of studying, lying on the table and sleeping, and forget to turn off the light, then the system will detect it, and then start the delay program, after a period of time, the table lamp will automatically turn off.
The main technical difficulty of this system lies in the collection and processing of human body infrared signals. Because the pyroelectric infrared sensor is used, when the human body enters its sensing range, the sensor will generate a few mV signal, and then through the signal processing circuit centered on BISS0001, the signal is secondarily amplified and filtered to prevent the outside world Signal interferes. After passing through BISS0001, the signal is converted into digital signal output, which is convenient for processing by single chip microcomputer.
The main design source produced by this system comes from life, so the innovation lies in dealing with some of the more common problems in life. Based on a pyroelectric infrared sensor that specifically senses the infrared signal of the human body, the BISS0001 signal processing circuit is processed by a single-chip computer to achieve the purpose of easy control. When the room is not bright enough and someone is nearby, the desk lamp will automatically light up, eliminating the trouble of touching the switch in the dark; when learning is too close to the desktop, resulting in an incorrect sitting posture, the system will prompt to correct the sitting posture To prevent myopia; when learning is too tired, the table lamp will automatically turn off when lying on the table for a while; when no one is present, the system will automatically turn off the table lamp to save energy. In addition to the anti-jamming technology used in the hardware part, the anti-jamming technology is also used in the software. When the interrupt 0 is generated, it is not executed immediately, but it is delayed to prevent it from entering the range of the detector 2 due to carelessness. To avoid misjudgment.
Although this system achieves the purpose of making life easier, the circuit is not simple enough. Because when there are multiple pyroelectric infrared sensors, the corresponding signal detection circuit is needed. The improvement lies in using a signal processing circuit to control multiple sensors simultaneously. Another disadvantage is that when the table lamp is turned on, the light intensity generated can easily interfere with the determination of the ambient light intensity by the photoresistor, causing misjudgment. The current processing method is to place the sensor part and the control part separately.

Design impression:
The design idea of ​​this system comes from life, so the functions it has are set for the convenience of life. Therefore, the idea of ​​making intelligent desk lamp came into being. First, in consultation with the teacher, the project was certified, the feasibility of the project was determined, the main difficulties and possible problems of the project were listed, and the focus of future production was determined. Next, conceive and list the general framework. Then use PROTEL to draw the circuit schematic according to the frame diagram.
After rigorously certifying the circuit schematic, the welding circuit was started. Because the main object is human, the pyroelectric infrared sensor is used. This sensor is specially used to receive the signal of about 10um generated by the human body, and the signal generated by BISS0001 is processed accordingly and converted into a digital signal that can be processed. During the welding process, it is found that if two photoresistors are used, it may cause misjudgment of the single chip microcomputer. Therefore, combining two photoresistors not only simplifies the circuit, but also improves the stability of the system. When the signal detection and processing part is completed, the test is started to determine whether the circuit is soldered correctly. In the process of debugging the circuit, external interference must be eliminated, especially infrared interference from nearby heat sources. First, set BISS0001 to a non-repetitive triggering method with a relatively long delay time in order to obtain a stable output signal, and connect the pin of the receiving photocell to a high level, making BISS0001 think that it has been in darkness for easy observation. During operation, when a person is away, BISS0001 outputs a low level, which meets the requirements; however, the signal changes irregularly when the person approaches. Using an oscilloscope to measure each pin of BISS0001, it was found that the main source of instability was the sensor. Therefore, with no better replacement, the current pyroelectric sensor had to be used.
Next is the digital circuit part, mainly composed of 80C51, 74LS138, LM324, DAC0832. The digital circuit part is relatively simple. After the welding is completed, write a new program to scan each port to show that the digital circuit is feasible.
After a preliminary test of the circuit part, the main problems were solved; therefore, the corresponding program was written according to the hardware. After the KEIL software simulation, there was no syntax error, the data of each port was just what was needed, and finally the The software is burned into the microcontroller, and then the entire system is run.
Through this experiment, I am familiar with the development and production of circuits and the writing of papers. Many difficulties were encountered in the experiment, but they were solved by various methods.

Program reference source code (part)

ORG 0000H
AJMP MAIN
ORG 0003H
AJMP DET1; far detector
ORG 0013H
AJMP DET0; near detector

ORG 0050H
MAIN: MOV P0, # 00000001B; Set initial value DET0, DET1 can be triggered repeatedly, light off
MOV TMOD, # 00000010B; Method 2, 8-bit automatic reload counter
MOV TCON, # 00010000B; Turn on counter T0
MOV IE, # 10000111B; turn on all interrupts
SJMP $
; light turns on slowly
DET1: MOV P0, # 00000001B
CALL TIME0; lamp brightness delay 10ms
MOV P0, # 00000011B
CALL TIME0
MOV P0, # 00000101B
CALL TIME0
MOV P0, # 00000111B
CALL TIME0
MOV P0, # 00001001B
CALL TIME0
MOV P0, # 00001011B
CALL TIME0
MOV P0, # 00001101B
CALL TIME0
MOV P0, # 00001111B
CALL TIME1
RETI
; The light goes out slowly
DET0: CALL TIME1; 1 minute delay
MOV TCON, A
ANL A, # 1
JZ LOOP
MOV P0, #00001111B
CALL TIME0
MOV P0, #00001101B
CALL TIME0
MOV P0, #00001011B
CALL TIME0
MOV P0, #00001001B
CALL TIME0
MOV P0, #00000111B
CALL TIME0
MOV P0, #00000101B
CALL TIME0
MOV P0, #00000011B
CALL TIME0
MOV P0, #00000001B
RETI
LOOP: ret
;延时10ms
TIME0: SETB TR0
MOV R0, #250
MOV R1, #20
D_1: DJNZ R0, D_1
MOV R0, #250
DJNZ R1, D_1
CLR TR0
RET
;延时1分钟
TIME1: SETB TR0
MOV R0, #250
MOV R1, #200
MOV R2, #60

Due to space limitations, only part of the code, please download the complete code by yourself

Finally, if you have any comments or suggestions, you are welcome to leave a message to me, let us learn together and progress together.
If you need the complete code or design file, please leave a message or private message me below.

Thank you!

Published 97 original articles · 200 praises · 80,000+ views

Guess you like

Origin blog.csdn.net/weixin_44212493/article/details/104335104