Shenzhen ZTRON Microelectronics Co., Ltd
Telephone
0755-8299 4126

MCU

Automatic light control curtain MCU


Design and realization of automatic light control curtain based on single chip computer


With the development of high-tech and electronic devices, people's living environment has been greatly improved, and smart homes have been realized. Smart curtains are a part of smart home. At present, the research on smart curtains is based on visual gestures, infrared remote control and other designs. Many studies only stay in the scheme design, or the design is cumbersome and costly, or lacks human considerations. This paper proposes an automatic curtain system based on single-chip microcomputer control, which can not only solve the inconvenience of pulling the curtains by hand every day, but also show the convenience and grade of life, and can also automatically control the opening and closing of the curtains according to the light and darkness to adjust the indoor light. This design is a light-controlled curtain based on AT89C52 single-chip microcomputer control. The hardware part of the system mainly uses the signal generated by the photosensitive sensor as the input signal of the single-chip microcomputer to control the motor; the software part uses C language for programming. Considering the user's habits and weather reasons, this program also sets a selection switch, and the user can choose the automatic or manual control mode at will when using the curtains. The system has the characteristics of humanized design, economical and practical, and high reliability.


1. The overall design scheme of automatic light control curtains


This design is realized as shown in block diagram 1, AT89C52 single-chip microcomputer is the core control device. The photoresistor is used as the light collector. After the photoresistor collects the photoelectric signal, it is converted into a digital signal by the sensor PCF8591. The single-chip microcomputer reads the digital signal and sends it to the motor driver chip ULN2003, which drives the 28BYJ48 stepper motor to perform forward and reverse rotation, thereby realizing light control. Function. The 28BYJ48 stepper motor is a four-phase eight-beat motor with a voltage of DC5V~DC12V. When a series of continuous control pulses are applied to the stepper motor in a certain order, it can rotate continuously. Each pulse signal changes the energization state of a certain phase or two-phase winding of the stepping motor once, which corresponds to a certain angle of rotation of the rotor. When the change of energization state completes a cycle, the rotor turns through one tooth pitch.


Using the principle of light control, when the light intensity is greater than 130lx, the curtain will automatically open; when the light intensity is less than 50lx, the curtain will automatically close; when the light intensity is between 50lx and 130lx, the state of the curtain will remain unchanged.


2. Main hardware design of automatic light control curtain


2.1 SCM system


AT89C52 is a low-power, high-performance CMOS 8-bit microcontroller produced by STC, with 8k in-system programmable Flash memory. AT89C52 uses the classic MCS-51 core, but has made a lot of improvements to make the chip have functions that traditional 51 single-chip microcomputers do not have. On a single chip, with smart 8-bit CPU and in-system programmable Flash, AT89C52 provides a highly flexible and ultra-effective solution for many embedded control application systems. The minimum system has a clock circuit, a microcontroller, a reset circuit, input/output devices, etc.


2.2 Photoelectric sensor signal acquisition module


The photoelectric sensor is used to collect light signals. The chip adopts PCF8591, which is a chip integrated with a photoresistor. After the photoresistor collects the light intensity signal, PCF8591 performs A/D conversion and outputs a digital signal. The module chip adopts PCF8591 integrated module, which has a power indicator light, and the indicator light will be on after the module is powered, so that it is convenient to observe the short circuit situation during debugging. The module has a DA output indicator light. When the module DA output interface voltage reaches a certain value, the panel will light up.


2.3 Motor drive circuit


ULN2003 is a high-voltage, high-current Darlington transistor array series product, which has the characteristics of high current gain, high working voltage, wide temperature range, and strong load capacity. It is suitable for various systems that require high-speed and high-power drives. ULN2003 is small in size, directly welded near pin 40 of the microcontroller, and connected with the power supply of the microcontroller, reducing the connection of power lines. In hardware design, in1 of the driver chip is connected to the p0.0 port of the microcontroller, in2 is connected to p0.1, in3 is connected to p0.2, and in4 is connected to p0.3. Also according to the position of the motor, directly plug in and connect it, and place the switch. The motor part can be directly connected with a straight socket and a driver. At dawn, the photosensitive sensor receives a high level, and the stepper motor rotates forward and clockwise according to the program, and the curtain is slowly opened at a certain speed. When it reaches the limit position, the curtain touches the travel switch SW3 on the right. , the switch is closed and the enabling terminal is closed, and the motor stops rotating. On the contrary, the AD value collected by the photosensitive sensor triggers the output of low level, the motor rotates counterclockwise, and the curtain opens.


2.4 Clock circuit design


The clock circuit is composed of two ceramic capacitors C2, C3 and a quartz crystal oscillator. The size of C1 and C2 is 30pF, and the quartz crystal oscillator is a 12M crystal oscillator. The two capacitors C1 and C2 are connected in parallel, and then connected in series with the quartz crystal oscillator. The two ports X1 and X2 of the clock circuit are respectively connected to the XTAL1 and XTAL2 pins of the microcontroller, and the internal oscillator can generate self-oscillation. In addition, to check whether the crystal oscillator has an oscillation effect, you can use an oscilloscope to see the sine wave output by XTAL2, or you can use a multimeter to measure it. You must adjust the gear to DC. When measuring, you will find that the unstable voltage is around 2V .


2.5 Manual reset button circuit connection


When people press the button by hand, the +5V level of the power supply will be directly connected to the RST terminal. Due to the relatively slow manual ability of the human being, the button will remain on for tens of milliseconds, and the human eye has a persistent visual effect. Therefore, the reset circuit can be manually reset to meet the time required for the reset. The S1 port of the reset circuit is connected to the RST port of the single-chip microcomputer. The RST port has a reset function. When the single-chip microcomputer is powered on, a high level with a width of more than two machine cycles (24 oscillation cycles) will appear on this pin, so that MCU reset. Therefore, the reset circuit is connected with the RST port of the microcontroller.


2.6 Forward and reverse button circuit design


Due to the external weather and the need to open and close the curtains at ordinary times, this design adds two manual buttons to control the forward and reverse of the curtains, so that the design meets the requirements of humanization. When you need to close the curtains during the day, just press the reverse button, and the curtains will close automatically; otherwise, the curtains will open automatically. The p2.0 and p2.1 of the button are respectively connected with the special interface p3.2 and p3.3 of the single-chip microcomputer. The second functions of these two I/O ports are the external interrupt INT0 port and the external interrupt INT1 port of the single-chip microcomputer respectively. This enables manual functionality.


3. Software design of automatic light control curtain


The programming language of single-chip microcomputer is mainly assembly and C language. C language programming software has relatively complete library functions, which has many advantages such as fast speed, high efficiency, portability, and direct hardware control. Therefore, this design is realized by C language. The software consists of a main program, a display subroutine, a delay subroutine, and a key scanning program. The initialization part includes the initialization of the 1602 display screen and the initialization of the I/O port of the control stepper motor; the acquisition and display part realizes that the voltage value of the collected photoresistor is displayed on the 1602 display screen and converted into a brightness display; the interrupt part mainly reflects In the realization of the button function, the button part uses an interrupt mechanism to ensure the real-time performance of the button. Two buttons are used, one manually controls the opening of the curtain, and the other manually controls the closing of the curtain; the motor control part intelligently controls the opening and closing of the curtain according to the brightness of the environment.


In short, the automatic light control curtain realizes the function of automatic switch according to the intensity of the outside light. Taking into account the different living habits of individuals, a humanized design has been carried out, and a manual switch has been added to realize the automatic switch while retaining the function of the original curtain. The overall structure of the design is simple, the price of the components is low, the design cost of the product is reduced, the device is economical and reliable, the control is flexible, and it has a certain market application prospect.


The above are the details of the design and implementation of automatic light control curtains based on single-chip microcomputers introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. We have rich experience in customized development of smart electronic products, can evaluate the development cycle and IC price as soon as possible, and can also calculate the PCBA quotation. We are the agent of Sonix MCU and Yingguang MCU agent, selling and developing MCU and voice IC solutions of Sonix and Yingguang. We act as an agent and develop ICs and solutions of Jieli, Ankai, Quanzhi, realtek and other series, and also develop BLE Bluetooth IC, dual-mode Bluetooth module, wifi module, and Internet of Things module. We have hardware design and software development capabilities. Covering circuit design, PCB design, single-chip microcomputer development, software custom development, APP custom development, WeChat official account development, voice recognition technology, Bluetooth development, wifi technology, etc. It can also undertake the research and development of smart electronic products, the design of household appliances, the development of beauty equipment, the development of Internet of Things applications, the design of smart home solutions, the development of TWS earphones, the development of Bluetooth earphone speakers, the development of children's toys, and the development of electronic education products.


  • TOP