With the development of electronic technology, residents generally use electronic thermometers or thermometers that come with perpetual calendars to measure indoor temperature. However, with the increasing severity of environmental pollution and the improvement of people's requirements for quality of life, people are gradually paying attention to the detection of indoor humidity, carbon dioxide concentration and light intensity. However, so far, there is no suitable and applicable instrument for home-type detection of humidity, light intensity and CO2 concentration. The traditional method in small warehouses is to use test equipment such as hygrometers, bimetallic measuring meters and humidity test papers to conduct manual detection and ventilate, dehumidify and cool down warehouses that do not meet the temperature and humidity requirements. This manual testing method is time-consuming, labor-intensive, inefficient, and the test temperature and humidity have large errors and randomness. Therefore, we need a temperature and humidity measuring instrument with high cost performance.
This paper designs and develops a novel, convenient, practical, and simple-structured multifunctional measuring instrument, which is suitable for places such as homes, warehouses, and greenhouses where environmental detection is required. The design displays the monitored results through LCD, and users can effectively adjust related equipment according to the monitoring results to achieve an ideal environmental state.
1 System Design
1.1 Design Task
This paper implements a multifunctional measurement system based on STC microcontroller, which can realize the functions of humidity detection, temperature detection, CO2 concentration detection, indoor light intensity detection, and time and date display. The measurement range of humidity is 20~90%RH; the detection range of temperature is -55~+125℃; the measurement range of CO2 concentration is 350~10000ppmCO2; the measurement range of indoor light intensity is 0~2500lux; the system displays the current time and date, and the current time and date can be modified by pressing keys.
1.2 Design scheme and working principle
The multifunctional detection system includes: power module, controller, temperature detection module, humidity detection module, illumination detection module, CO2 concentration detection module, clock module, keyboard input module, LCD display module. As shown in Figure 1.
This control system uses the STC12C5A60S2 single-chip microcomputer as the control core. The single-chip microcomputer has the characteristics of high speed, low power consumption, and super strong anti-interference, and has 8-channel 10-bit precision AD conversion; temperature and humidity detection is realized by digital temperature detection sensor DS18B20 and humidity detection sensor DTH11. Since the digital sensor outputs digital quantities, data processing is relatively simple, and these two sensors have a high cost performance; the clock module uses the more commonly used DS1302 clock chip, and the communication between the controller and the clock chip is realized to obtain the comparison More accurate time value, in addition, the clock can be calibrated by key operation; the detection of illumination and CO2 concentration is more complicated. Since the output signal of silicon photocell and CO2 detection sensor is a weak analog signal, it is necessary to condition the small signal obtained, and send the conditioned signal information to the AD port of the single-chip microcomputer to obtain the digital quantity that the single-chip microcomputer can process; all test results and date and time are displayed by LCD; since the amplifier in the signal conditioning circuit adopts dual power supply, the power module uses AC 220V to ±5V power module. 2
Hardware Circuit Design
2.1 Control Circuit
The control circuit of the system is the minimum system composed of STC12C5A60S2 single-chip microcomputer as the control core. In addition, in order to facilitate program downloading, a program download interface circuit based on CH340 is designed, and the circuit diagram is shown in Figure 2.
2.2 Detection circuit
According to the different output signals of sensors, they can be divided into digital sensors and analog sensors. Different signal types lead to different detection circuits.
2.2.1 Temperature and humidity detection circuit
Since both the temperature sensor DS18B20 and the humidity sensor DTH11 are digital outputs, the detection circuit is very simple. In order to prevent the appearance of uncertain signals, a 4.7k pull-up resistor is required at the output end of the signal, as shown in Figure 3.
[page]
2.2.2 Illuminance and CO2 concentration detection circuit
Since the light detection uses silicon photocells, the signal is a small analog output, so the signal needs to be conditioned. The output of the CO2 sensor MG811 is also a small analog voltage signal. Its parameters are shown in Table 1.
The principle of measuring light intensity by silicon photocell is the photovoltaic effect, that is, it is a semiconductor device that directly converts light energy into electrical energy. From the characteristic curve of silicon photocell, it can be seen that the output current of photovoltaic cell is more linear than the output voltage, so its current characteristic is detected here. From the experimental test, it can be obtained that the indoor light intensity is generally 0-2500 lux. At this time, the output current of silicon photocell is about 0-0.15mA. A 100 Ω resistor is connected in parallel at both ends of the silicon photocell, and the output voltage at this time is about 0-15mV.
In order to condition the small signal into a signal suitable for single-chip microcomputer processing, the small signal is amplified and filtered. First, the small signal is amplified and processed, and a high input impedance differential amplifier is used here. Secondly, the signal output by the amplifier passes through a second-order active low-pass filter. Finally, the signal enters the AD port of the single-chip microcomputer. The signal conditioning circuit is shown in Figure 4.
(1) Difference amplifier circuit
Because R3=R4, R6=R8=R7=R9 in the circuit, the total gain of the two-stage differential mode can be derived as follows:
Usually, the gain of the first stage should be as high as possible, and the gain of the second stage is generally 1 to 2 times. Here, the first stage is selected as 100 times and the second stage is 1 times. Then R6=R7=R8=R9=10KΩ is selected, and good matching is required. Generally, metal film precision resistors are used, and the resistance value can be selected between 10KΩ and several hundred KΩ. Then
first determine R5, which is usually within 1 to 10kΩ. Here, R5=1kΩ is selected, and R3=99R1=49.5 kΩ can be obtained from the above formula.
Take the nominal value of 51kΩ. Usually, R1 and R2 should not exceed R5/2. Here, R1=R2=510Ω is selected to protect the op amp input stage.
A1 and A2 should use op amps with low temperature drift and high KCMRR, and the performance consistency should be good.
(2) Active low-pass filter circuit
Since the input and output signals of the filter circuit are DC signals, the cutoff frequency selected in the calculation is 3Hz. The filter capacitor C1=C2=1 μF.
From formula (3) and (4), we can get R=53078 Ω, A0=2, so here we take R10=R11=51k.
The actual amplification factor of the signal after the signal conditioning circuit is A=200. For the CO2 sensor, according to the different input signals, choose appropriate R3 and R4, and the gain of its signal conditioning circuit is 80.
2.2.3 Clock module
This design uses a high-performance, low-power real-time clock chip DS1302 launched by Dallas, USA. The chip uses the SPI three-wire interface to communicate synchronously with the CPU, and can use burst mode to transmit multiple bytes of clock signals and RAM data at a time. The real-time clock can provide seconds, minutes, hours, days, weeks, months and years. It can automatically adjust when a month is less than 31 days, and has a leap year compensation function.
The working voltage is as wide as 2.5~5.5V. It adopts dual power supply (main power supply and backup power supply), and the backup power supply charging mode can be set, providing the ability to charge the backup power supply with a trickle current. The circuit connection is shown in Figure 5.
3 Software Design
3.1 Software System Design
The system software mainly consists of two parts: data acquisition and data display. When the system is powered on, the system is first initialized; then the flag is judged to determine whether the clock is currently set. If yes, the clock is adjusted by the key. If not, all data is collected and processed accordingly; finally, the collected data is displayed on the LCD. The system program block diagram is shown in Figure 6.
3.2 Partial detection software design
For light intensity detection and CO2 concentration detection, there is a conversion from analog to digital, so the accuracy of the AD converter needs to be considered. In order to obtain a more accurate detection value, the 10-bit AD conversion interface of STC12C5A60S2 is used here, that is, its accuracy is 1/(210-1).
For light intensity detection, the output voltage after the signal conditioning circuit is 0~3V, and the corresponding light intensity is 0~2500lux. Assuming that the value after AD conversion is A, the corresponding light intensity at this time is E, as shown in formula (5).
Simplified: E=(12500×A)/3069. Therefore, the detection of light intensity can be realized through program writing.
4 Conclusion
A multifunctional measurement system based on STC12C5A60S2 is designed. Through theoretical analysis, actual circuit welding and related program writing, the physical object is designed. Through testing, the functions of temperature and humidity detection, CO2 concentration detection, indoor illumination detection and clock display are realized. The experimental results are good, and the measurement accuracy is within the actual calculation error range.
Previous article:What are the maskable interrupts of MSP430?
Next article:Design of welding temperature measuring instrument based on single chip microcomputer
Recommended ReadingLatest update time:2024-11-16 22:23
- Popular Resources
- Popular amplifiers
- Analysis and Implementation of MAC Protocol for Wireless Sensor Networks (by Yang Zhijun, Xie Xianjie, and Ding Hongwei)
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
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
- Hey guys, I can't find the following libraries on Cadence's Psipce
- First look at Texas Instruments' C2000 series
- [Project source code] Digital tube companion - binary to BCD
- Uncover the mystery of MOS tube damage! What other reasons do you know?
- Let's discuss whether GaN materials are a key technology in 5G applications.
- FPGA Basics (I)
- Sensortile.box
- [GD32E231 DIY Contest]——02. New project engineering and engineering configuration
- Please help me solve the following two pictures, mirror current source problem. Thank you very much
- TI's 10/15-cell Li-ion and Phosphate battery solutions