Design of intelligent desk lamp
Smart desk lamp is an electronic product, which can manually adjust the brightness of the desk lamp. It can measure the distance between the user and the desk lamp through the ultrasonic sensor, and realize the function of reminding the user. And can realize the function of automatically detecting whether someone is there. The desk lamp adopts LED energy-saving lamp, and the power is 3W when it works normally, which not only realizes intelligence, but also saves energy.
Keywords: intelligent LED table lamp ultrasonic intelligent energy saving
First, the principle analysis of hardware circuit
The hardware block diagram of this work is shown in the following figure (the dotted line part is not in the PCB board), which is mainly composed of power supply circuit, main control circuit, ultrasonic transmitting circuit, ultrasonic receiving circuit and LED driving circuit.
1. 1 power supply circuit
The power supply circuit is shown in the figure below. After 220V commercial power is input, it is transformed by 15V, rectified and filtered by flat bridge, and stabilized by 78 12, 79 12 and 7805 respectively. The DC voltage is 15V, and+12V and-/are obtained.
1.2 main control circuit
The main control circuit is shown in the following figure. Its main control core is AT89S52, which consists of the simplest minimum system, key circuit and ISP online writing circuit.
1.3 ultrasonic transmitting circuit
The ultrasonic transmitting circuit is shown in the following figure. Since the frequency of ultrasonic transmission is 40kHz, the frequency of 40kHz is generated by the multivibrator circuit of NE555, and then connected to the ultrasonic transmitter through the driving circuit composed of NOT gate, which greatly increases the ultrasonic transmission distance.
1.4 ultrasonic receiving circuit
The ultrasonic receiving circuit is shown in the following figure. After receiving 40kHz, the ultrasonic wave is amplified by TL084 10000 times, and then all the way to the three pins of the operational amplifier LM393. After comparison, LM 393 operational amplifier A outputs a stable square wave, which is inverted and stabilized by NPN transistor 8050, and the output current increases. The other path is input to the detector diode 1N60, and the output of diode 1N60 is filtered by resistor and capacitor, so the voltage amplitude is attenuated a lot, so TL084 amplification is needed in the later stage. When the ultrasonic reception is a stable waveform, the 8-pin output of TL084 is a stable voltage value. When the ultrasonic receiving waveform changes (that is, the measuring distance changes), the 8-pin output of TL084 will jump, so VR4 can adjust the amplitude of the jump, and then adjust VR3 to set a comparison voltage, so that the product can realize the function of detecting whether someone automatically turns off/on the desk lamp.
1.4LED lamp driving circuit
The LED lamp driving circuit is shown in the following figure. PT4 1 15 is a step-down constant current source with continuous inductor current conduction mode, which is used to drive LED. The input voltage range of PT4 1 15 is 6V-30V, and the output current is adjustable, up to1.2a. We output an adjustable PWM control PT4 1 15 by using the method of single chip microcomputer timer, and then control the duty ratio of PWM, which can realize the brightness level of LED and control PWM.
1.5 decoupling capacitor
The decoupling capacitor is shown on the right. A capacitor of 104 is connected to the power supply of each chip in PCB layout to eliminate some unnecessary interference, which greatly improves the anti-interference and stability of the circuit.
Second, the printed circuit board design
According to the schematic diagram, this circuit can be divided into five parts: power supply, ultrasonic emission, ultrasonic reception, main control and LED power supply drive. In the chassis shell provided by the chairman, the transformer is placed on the left side of the bottom plate; The positioning holes of the circuit board are four rectangles with a diameter of 3mm, which are vertically placed11cm *12cm; There are four buttons on the front panel and an ultrasonic transmitter and receiver on the back panel.
Printed circuit board
2. 1 power supply section
The placement of the power supply circuit is mainly related to the placement of the transformer, so the power supply is placed on the left side of the circuit board, with power input,-12V output,+12V output and +5V output from top to bottom.
2.2 ultrasonic emission
The emission of ultrasonic wave is controlled by P 1. 1 port of single chip microcomputer, and the signal generated by 555 is transmitted to the ultrasonic transmitter through inverter 74LS04. This part is divided into weak power supply part, and the generated high-frequency signal is easily disturbed, so it is also beneficial to install the ultrasonic transmitter in the upper right corner far from the power supply.
2.3 Ultrasonic reception
The ultrasonic signal is amplified by TL084, compared by LM393 operational amplifier, and then output to single chip microcomputer through 8050 inverter and voltage stabilization. The other path is attenuated by 1N60 detection, amplified by TL084, inverted by 8050, and output to single chip microcomputer. TL084 and LM393 are both powered by 12V power supply, so they should be close to the power supply. This is also beneficial to the installation of the ultrasonic receiving port.
2.4 Main control
From left to right, the circuit is receiving and transmitting in turn. The MCU is placed under the transmitter and receiver, the buttons are on the front panel, the button interface is placed on the lower right edge of the circuit board, and the download line interface is also placed on the edge, which is beneficial to programming.
2.5 LED power supply drive
The driving circuit is a patch, which has a small use area and is mainly influenced by 18V power supply and PWM control pin. Considering the priority of PWM, it is placed on the right side of the single chip microcomputer.
2.6 integrated circuits
The power line is the main artery of the whole system, so the line width of 50mil and the copper-clad circuit board are beneficial to improve the anti-interference performance of the circuit.
Third, software design.
3. 1 programming
According to the technical requirements, the functions realized by this program include pressing the power button to control the switch of the light and pressing the (AUTO/MUNE) button to switch the state. In the menu state, the software uses PWM mode and timer 0 to adjust the duty cycle of PWM, thus adjusting the brightness and flicker of the desk lamp. Moreover, when the distance detected by ultrasonic wave is less than 30CM, it will flicker due to external interruption of 0. In the automatic state, the software simultaneously detects whether there is anyone in the room under the basic function of the menu. Through the external interrupt 1 detection, the lights will be turned on when there is someone, and the lights will be turned off after 5 seconds when no one is detected.
3.2 program flow chart
3.2 source program
The programming environment is Keil Vision 2, and the programming is written online by ISP. The source program is as follows: