1 System overall design and function
The system uses a single-chip microcomputer to control the DS12C887 clock chip to accurately count, uses DS18B20 (1-Wire) to connect to the single-chip microcomputer to realize temperature collection, and displays the clock and indoor temperature on the LCD chip 12864 to control the temperature. When the temperature reaches 25℃, the air conditioner power supply is automatically closed, allowing the use of air conditioning. Under normal circumstances, when the timing reaches 7:00 (the time can be adjusted manually by independent buttons), the starting music is automatically played and the main power supply is closed to test the temperature in the room. When the time reaches 21:55, the ending music will be played, and the whole system will be shut down at 22:00. When the power is controlled at ordinary times, the system will have two working states: automatic control state and forced state.
1.1 Automatic control state (default state)
Two infrared sensors are installed at the door of the laboratory, set to 1 and 2 respectively. When a person passes through 1 first and then 2, it is set to enter, otherwise it is set to leave. Using photoresistors, when the indoor brightness is lower than the normal requirement and there are people, the lighting circuit can be turned on. When someone enters the laboratory in dark weather (or at night), the system controls the switch of the power supply of the laboratory table and the closing state of the lighting circuit through a relay. When the number of people is 1 to 10, one of the lights in the laboratory is turned on, and the power supply of 5 laboratory tables is closed and available for use; when the number of people is 10 to 20, 2 lights are turned on, and 10 laboratory tables are available for use... According to the number of people entering the laboratory, the number of available laboratory tables and the number of fluorescent lights turned on when the weather is dark are intelligently determined. When the number of people becomes zero again, 20 minutes later, the horn alarms, the relay is closed, the lights go out, and the power supply of all the opened laboratory tables is disconnected. Until someone enters again, the relay is closed and the power supply of the laboratory table is closed again. When the indoor lighting is sufficient, the lighting circuit does not work and the power supply of the laboratory table can be controlled.
1.2 Forced state
This state is to transmit data to the single-chip microcomputer (lower computer) through the computer switchboard (host computer). Connect the host computer and the single-chip microcomputer together, and control the single-chip microcomputer through serial communication to achieve the purpose of controlling the amount of power used in the laboratory. The laboratory lighting circuit and the laboratory table circuit can be fully connected, fully off, or a specific power supply can be turned on as required. The single-chip microcomputer can be queried by inputting instructions, and the number of laboratory people can be displayed on the host computer screen in real time.
2 System hardware design
2.1 Introduction to hardware composition and functions
of each device The hardware core components of the intelligent laboratory control system are composed of single-chip microcomputer STC89C52 chip, E18-B03N1 reflective infrared photoelectric switch, music chip, single bus temperature sensor DS18B20, clock chip DS12C887 and 12864 LCD with font library. Among them, the E18-B03N1 reflective infrared photoelectric switch adopts reflective type, and the adjustable distance of measurement is greater than 30 cm. There are 3 pins in total, one for power supply, one for ground, and the other for data line. When there is no induction closure, the data line is high level, and when someone passes by, the data line becomes low level. DS12C887: clock chip, when the power is off, the internal clock still moves, with clock timing function, and can set off alarms at a specified time within 24 hours. DS18B20: single bus temperature sensor, real-time reading of temperature signal, accuracy of 0.5℃.
2.2 Working principle and introduction of each part of system hardware
The hardware block diagram is shown in Figure 1.
[page]
(1) Using a single chip microcomputer (2) to control the circuit, the infrared photoelectric switch (4) is connected to (P3.2, P3.3) in the form of an external interrupt (8), and the digital tube (6) displays the number of people in the laboratory at this time.(2) When the number of people entering the laboratory is not zero, the external power supply circuit (5) controls the relay through the single chip microcomputer, and according to the number of people required, the lights are turned on and the laboratory table is closed.
(3) When the number of people becomes zero again, the single chip microcomputer timer (7) is used to time for 20 minutes. If no one enters within 20 minutes, the music piece will alarm through the speaker and the external circuit will be disconnected. If someone enters again, the external circuit (lighting circuit and laboratory table power supply circuit) will be closed by the single chip microcomputer according to the number of people.
(4) The single chip microcomputer (10) can be powered by the single chip microcomputer (2) and the relay control power supply. When there is no one in the laboratory or the computer is forced to shut down, the single chip microcomputer (10) will not work.
(5) LCD 12864 (14) is connected to the single-chip computer (10), and the LCD displays the following information: "Laboratory control system", year, month, day, week, hour, minute, second and temperature.
(6) DS12C887 clock chip (14) is used (in the case of power failure, the DS12C887 clock continues to run) to achieve accurate timing, and the current time can be adjusted by independent buttons. At the set specific time at night (such as: 21:53:20), the alarm alarm is given, an external interrupt (12) is sent, the music disc plays music (15) and delays power off, and starts playing music at the set specific time in the morning (such as: 7:00), and delays the closing of the main power supply on the mains line. At the same time, when the alarm time is reached and the music sounds, the music can be turned off in four ways: 1. manual button, 2. timer (11) reaches the set time of 20 minutes, 3. The number of people is zero, and 4. The host computer forces power off and turns off the music. At the same time, the above time can be adjusted by the independent button of the single-chip computer, which can determine the time in a more humane way.
(7) DS18B20 (16) detects the temperature, displays the temperature in the laboratory on the LCD, and turns off the air conditioning power when the temperature is higher than 25℃. Air conditioning is allowed.
2.3 Multi-chip computer communication system
STC89C52 is connected to an RS 232/485 converter to form a standard PC-chip computer communication interface, so that multiple single-chip computers can communicate with the PC serial port, and the PC (host computer) can communicate with multiple slave computers (single-chip computers) via serial ports. The host computer and the single-chip computer strictly implement the master-slave structure in the form of responsive communication control, with the host computer as the master and the slave computer as the slave. The slave computer cannot actively send commands or data, and everything is controlled by the host computer. At any time, the host computer only transmits information to one slave computer, and the slave computers cannot communicate directly with each other. In a multi-computer communication system, the host computer sends commands to each slave computer by calling the name to realize the master control of the system. While executing tasks, the host must continuously poll the slave to monitor the status of the slave, receive requests from the slave, or send commands to the slave. In order to control the lighting circuits of multiple laboratories and the power supply of the laboratory table in real time. According to the requirements, the on and off of the circuit outside the laboratory, the on and off of the power supply at a specific location, and the real-time query of the number of people in the laboratory are forcibly controlled and displayed on the PC screen. That is, when the command is entered, the number of people in a single microcontroller is transferred to the host computer to query the number of people in the laboratory in real time.
3 System software design
The single laboratory software control system is mainly composed of two single-chip microcomputers. The process of single-chip microcomputer 1 and single-chip microcomputer 2 is shown in Figure 2 and Figure 3.
[page]
3.1 Working principle of single chip microcomputer 1
(1) Two E18-B03N1 infrared photoelectric switches (respectively marked as A and B) are connected to the single chip microcomputer external interrupt ports P3.2 and P3.3 in the external interrupt mode. When someone enters the classroom, infrared switch A is first blocked, and the INT0 terminal first receives the low level "0" generated by the infrared switch, triggering the single chip microcomputer interrupt. In the corresponding interrupt program, the number of people is calculated by adding 1, and the interrupt enable of INT1 is turned off in the program, so that INT1 will not trigger the interrupt, and start the delay. After a certain period of time, the interrupt enable of INT1 is turned on by the timer interrupt; Go out - when someone leaves the classroom
, the infrared photoelectric switch B light is first blocked, and the INT1 terminal first receives "0", triggering the single chip microcomputer interrupt, and the number of people is reduced by 1. At the same time, the interrupt enable of INT0 is turned off in the program, and the delay is started. After a certain period of time, the interrupt enable of INT0 is turned on by the timer interrupt. Finally, the number of people in the laboratory at this time is displayed through the digital tube. The working status of the external circuit is determined according to the real-time number of people.
(2) When the upper computer queries the number of people in the lower computer, the number of people can be stored in the SBUF register of the microcontroller and queried through the upper computer.
(3) The upper computer can control the lower computer to use relays through level conversion to achieve the purpose of controlling the power supply of the laboratory.
3.2 Working principle of microcontroller 2
Microcontroller 2 mainly queries the indoor temperature in real time through DS18B20, uses LCD display, and judges that when the temperature is greater than the specified temperature (such as 25℃), the air conditioner switch is allowed to close. At the same time, DS12C887 reads the real-time time (the time can be adjusted through independent buttons) and displays it through LCD. Because there is only one alarm interrupt inside the chip, the DS12C887 chip interrupt and 89C52 single chip are used for mixed control. When a specified alarm time is reached, the microcontroller rewrites the new alarm time until the new alarm time takes effect, and then writes the first alarm time again to achieve the effect of dual alarm timing. When the alarm rings at night, in order to leave enough delay time, the microcontroller timing method is used to delay a specific time (such as 20 minutes). At the same time, considering that different laboratories have different requirements for sound, the manual button and the upper computer forced method are used to close it. When the number of people is zero, or the delay time is reached, all the circuits in the laboratory are closed. Until the alarm is turned on the next day, the external circuit is closed again.
4 Conclusion
Through practice, the intelligent control system of this laboratory has better realized the above basic functions, and has been approved by the head teacher of our school's microelectronics laboratory, and is being applied to our school's microelectronics laboratory. However, due to the rush of time, there are still some shortcomings. For example, when two people squeeze through the door, the infrared device cannot detect it; the front and rear doors are not considered (that is, the problem of communication between the two microcontrollers). These problems need to be further improved in the future.
Previous article:Design of a new electric bicycle speed control system based on C8051F313
Next article:Application of single chip microcomputer technology in data collection and monitoring process
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Homemade Raspberry Pi 3 board 12 times bigger, and it works
- Learn 5 key technical points about TI BAW technology
- Procurement of ADI
- GD32L233C-START Development Board Study Notes (Part 2)
- Evaluation board EasyARM-RT1052 data
- President of the Chinese Academy of Sciences: Turn the US bottleneck list into a scientific research list
- Siemens Industrial Automation Data Collection (August 9, 2019)
- The troubles of capacitor testers in traditional mode - Part 1
- Playing with Zynq Serial 19——[ex02] A happy running water lamp based on Zynq PL
- 5G O-RAN All-in-one Small Base Station Hardware White Box Reference Architecture