“With the development of social economy and the continuous progress of science and technology, the temperature and humidity of the environment need to be limited in many cases. Therefore, temperature and humidity alarms must be installed in some specific environments for monitoring. To this end, this paper uses the integrated temperature and humidity sensor HM1500 to measure the temperature quickly and easy to use, and combines the powerful functions of the MSP430 microcontroller to design a monitoring system to monitor the temperature and humidity in real time for over-limit alarms. The system is accurate in measurement, convenient in debugging, can record alarm information in real time, facilitates troubleshooting by staff, and can be widely used in occasions with harsh conditions and inconvenient access for personnel.
Authors: Gao Xiang, Chen Zhihui
With the development of social economy and the continuous progress of science and technology, the temperature and humidity of the environment need to be limited in many cases. Therefore, temperature and humidity alarms must be installed in some specific environments for monitoring. To this end, this paper uses the integrated temperature and humidity sensor HM1500 to measure the temperature quickly and easy to use, and combines the powerful functions of the MSP430 microcontroller to design a monitoring system to monitor the temperature and humidity in real time for over-limit alarms. The system is accurate in measurement, convenient in debugging, can record alarm information in real time, facilitates troubleshooting by staff, and can be widely used in occasions with harsh conditions and inconvenient access for personnel.
1. System structure and overall design
The overall design of this system is shown in Figure 1. This scheme adopts the method of designing temperature and humidity sampling circuits respectively, and converts the current signal collected by the integrated temperature sensor AD590 and the voltage signal collected by the humidity sensor HM1500 into a voltage signal within a given range. Then the voltage signal is read in by the AD sampling port of the microcontroller MSP430F1232, if the temperature is less than the threshold value or the humidity is greater than the threshold value, an alarm signal is given. The threshold value can be set by pressing the keys. At the same time, the system can also send the collected temperature and humidity values to the host computer according to a given protocol by interrupting.
2. Device selection
2.1 MSP430F1232 microcontroller
MSP430 series microcontroller is a powerful ultra-low power consumption 16-bit mixed-signal processor introduced by TI. This series of single-chip microcomputers is widely used in portable instruments, smart sensors, practical testing instruments, motor control and other fields due to its extremely low power consumption, powerful processing capabilities, rich on-chip peripheral modules, and convenient and efficient development methods. In order to maximize the use of microcontroller ports and on-chip peripherals and reduce the design cost, this design selects MSP430F1232. The microcontroller has 3 parallel ports, an RS485 serial communication port, and a built-in 10-bit AD sampler, which can fully meet the temperature and humidity sampling. accuracy requirements.
2.2 AD590 temperature sensor
AD590 is a two-terminal integrated temperature-current sensor produced by AD Company in the United States. The device is small in size, light in weight and stable in performance. The temperature measurement range is -50～+150℃; the linear current output is 1μA/K; the linearity is good, the measurement accuracy is ±0.3℃; the power supply voltage range is 4～30V. When the power supply voltage is between 5 and 10 V and the voltage stability is 1%, the error is only ±0.1°C.
2.3 HM1500 Humidity Sensor
The linear voltage output type integrated humidity sensor HM1500 is designed and manufactured with the patented humidity sensitive capacitor HS1101. Its humidity measurement range is 5% to 99% (relative humidity); the relative humidity accuracy is 3%; the operating temperature is -30 ~ +60 ℃ ; The working humidity range is 0~100% (relative humidity); the power supply voltage is 5V (maximum voltage DC16V); the output DC voltage is 1~4 V; the response time is 5s, which is suitable for industrial-grade occasions.
3. Signal conditioning circuit design
3.1 Design of temperature measurement circuit
Taking into account the output current source characteristics of the AD590 temperature sensor, the designed temperature signal measurement circuit is shown in Figure 2. The temperature measurement range of this circuit is -10～+500℃. AD590 is powered by 15V voltage; resistor R1 is used to adjust the zero point; resistor R3 is a precision resistor used to adjust the gain. The non-inverting end of the operational amplifier inputs a 2.50V precision reference voltage, which is provided by TL431. The current of AD590 is input to the IN terminal, and the voltage obtained by the corresponding conversion is output to the OUT terminal. According to the characteristics of AD590, at -10°C, the flowing current is 262.2μA. The design makes this part of the current all flow through R1 and R2, and then the increased current flows through R3. The output voltage of the OUT terminal is:
When the temperature changes between -10~+50℃, the voltage will change linearly in the reverse direction between 2.5~0V. Adjusting the resistance value of R1 can eliminate the zero point error of different sensors.
3.2 Humidity measurement circuit design
The output voltage of the integrated humidity sensor HM1500 varies linearly with humidity between 1 and 4 V. Considering the single power supply characteristics of this system, the designed humidity signal acquisition circuit is shown in Figure 3. The humidity measurement range of this circuit is 0 to 100%. .
Since there is no negative voltage in this circuit, the main body of the circuit adopts a differential subtraction circuit, precision resistors R3=R6=2.4kΩ, R4=R7=2kΩ, and the gain can be adjusted with these four resistors. The humidity voltage signal measured by the HM1500 sensor is input from the IN terminal. The other side of the differential inputs Vs. A voltage of about 1.0 V can be obtained after a precise voltage divider of 2.5 V is provided by TL431. From this, the calculation formula of the output voltage can be obtained as:
If the input voltage varies from 1 to 4 V, the output voltage varies from 0 to 2.5 V accordingly. Adjusting R1 can eliminate the zero error of different humidity sensors.
4. Display storage and serial communication circuit design
The system adopts three independent buttons and four-digit seven-segment digital tube dynamic scanning display mode, and data storage is adopted. EEPROM chip AT24C02 to store the set temperature and humidity sensor address, temperature and humidity alarm threshold, and alarm records. All kinds of collected data and stored alarm information can be sent to the upper host controller for processing according to the specified protocol.
Figure 4 shows the key display, data storage and serial communication circuits in the system. In the figure, after the single-chip microcomputer collects the temperature and humidity data from ADIN1 and ADIN2 ports, it first sends the humidity value to the digital tube for display, and lights the humidity indicator at the same time, indicating that the humidity is now displayed. The temperature and humidity display can be switched by pressing the No. 2 key and No. 3 key. The No. 2 key displays the humidity, and the No. 3 key displays the temperature. When the temperature is displayed, the corresponding indicator light will also be lit. If it is detected that the temperature and humidity exceed the threshold, the alarm light will be lit to indicate that the data exceeds the limit. Press key 1 to set the corresponding temperature and humidity threshold and sensor address. After the data setting is completed, the I2C bus protocol can be programmed to simulate the I2C bus protocol through the two IO ports to store the data in the designated location, so that the data can be read normally when the power is turned off and then turned on again. Due to the limited IO ports of the microcontroller, the system uses two SN74HC373 chips to expand 8 IO ports to meet the design requirements. In order to ensure level compatibility, this part of the circuit is powered by 3.3V voltage. After the data acquisition and conversion is completed, the system can directly connect to the MAX3485 communication chip through the UASRT (asynchronous serial communication port) of the single-chip microcomputer, so as to transmit the data to the upper computer according to the specified protocol.
5. Software design
The software design of this system is written in C language, mainly through the 10-bit AD sampling module of the MSP430F1232 microcontroller to read the temperature and humidity voltage signal of the port, and convert it into the actual temperature and humidity value according to the corresponding conversion formula and store it. Then send it to the digital tube display or send it to the host computer through the RS485 serial port as needed. In addition, the software can also simulate the data storage of the I2C bus.
Figure 5 shows the main circulation flow of the system. After the system is powered on, it first reads the address and temperature and humidity thresholds stored in the EEPROM, then enters the loop state to sample the temperature and humidity signals, then processes and stores the collected data, and performs key flag bit operations in the loop. judge. If set, the corresponding key processing is performed.
Figure 6 shows the timer interrupt flow of the system. When the system enters the interrupt, it first judges whether a key is pressed by judging whether the input level of the corresponding IO port jumps low. position bit. Then call the display refresh program, and send the latest collected data to the digital tube display. Finally, judge whether the collected data exceeds the threshold, and light up the indicator light or alarm light accordingly. After the above operations are performed, the interrupt returns.
The biggest feature of this system is accurate measurement, simple structure, convenient debugging and use, high cost performance, can be used alone, or can be connected with the host computer. In order to ensure the stability of the whole system, this system also adopts the power-on reset circuit of the microcontroller in the hardware design, and adds a watchdog and software traps in the software design. Experiments show that the device is reliable in operation, small in measurement error, and has a good application effect. Therefore, it can be widely used in industrial environments where there is an over-limit alarm requirement for temperature or humidity.