Design of Signal Acquisition and Processing System for Temperature Sensor Experiment Instrument

Temperature is one of the most basic and important parameters in industrial and agricultural production, scientific research and daily life. Therefore, how to realize accurate, rapid and even extreme temperature measurement is one of the important issues facing the society today. The temperature sensor experimental instrument in this project can realize the temperature detection of the current environment, and can realize the detection in different occasions and environments through the setting of upper and lower limits, and upload the measured data to the upper computer for display and storage. The purpose of this project is to design a temperature sensor experimental instrument. The experimental instrument is based on the STM32 single-chip microcomputer as the core, and uses the four-wire thermistor sensor to collect the current temperature value. Through the STM32 single-chip microcomputer, the analog value is converted into digital value, and the collected temperature is displayed on the digital tube. At the same time, the experimental instrument converts the temperature signal into thermoelectric emf signal through the k-type thermocouple, and converts the analog signal into digital signal output through the MAX6675 module. Finally, the data converted by MAX6675 is read through the SPI serial port. The operation results show that the temperature sensor can measure the temperature of the current environment, and the design scheme is reasonable and basically meets the design requirements.


Introduction 1.The purpose and significance of the research
Temperature is a physical quantity that indicates the degree of hot and cold objects, and is one of the most basic and important parameters in industrial and agricultural production, scientific research, and daily life. Especially in the development of physics, chemistry, energy, materials and other disciplines, temperature detection is indispensable, such as temperature control of steelmaking and ceramic kilns, environmental control of fruit and vegetable storage, glass production, chemical reaction process parameter design, material thermal physical property analysis , Crystal growth, body temperature measurement and weather forecast are all closely related to temperature detection Error! Reference source not found. . However, with the rapid development of modern science and technology, polymer materials, composite materials and biotechnology have been rapidly developed and in-depth research, and its research is applied to related precision tests such as thermal analysis and calorimeter instruments, thermophysical property testing instruments, analytical instruments and measuring furnaces. Instruments, and these instruments have increasingly higher requirements on the temperature detection range, detection accuracy and temperature response time Error! Reference source not found. .
The purpose of this project is to design a temperature sensor experimental instrument. The temperature experimental instrument collects the current temperature through the four-wire thermistor and K-type thermocouple, and sends the collected temperature data to the host computer for display and storage. In the early stage of designing the experimental instrument, by studying the temperature experiment instrument already on the market, you can clearly understand the basic structure, characteristics and working principle of the existing temperature experiment instrument. At the same time, you can understand the shortcomings of the existing temperature experiment instrument, so on this basis, design a multi-function, intelligent, easy to carry, simple operation, high measurement accuracy temperature sensor experiment instrument.

Research status and development trends at home and abroad
Resistance type, thermocouple type and quartz resonance type are commonly used temperature detection methods. The basic principle of their temperature measurement is that changes in temperature cause changes in their physical parameters. The development of temperature sensors is divided into the following three stages: traditional discrete temperature sensors, analog integrated temperature sensors/controllers, and intelligent temperature sensors. Nowadays, new temperature sensors are developing in the direction of digital, intelligent and network. With the rapid development of science and technology, a new generation of temperature detection elements are constantly appearing and improving. At present, most of the ultra-high precision measurement uses standard platinum resistance temperature sensors. For example: The measurement accuracy of the 1575 thermometer in the 15XX series of ultra-high-precision temperature measuring instruments of the Hart Company in the US industry is ±0.001°C.
Domestically, Tsinghua University uses a quartz crystal sensor as a temperature measuring element to convert the analog quantity of temperature change into a digital quantity of quartz crystal oscillation frequency, and the temperature value can be calculated by measuring the frequency. In high-precision temperature measurement, domestic companies do not have the key technology for producing standard platinum resistors and thermistors, and the manufacturing technology of such foreign sensors is a commercial secret. The use of these two sensors in my country can only rely on imports.
In summary, my country has made tremendous progress in the development of temperature sensors. However, most of the temperature measuring instruments in my country have low technical level, poor product quality, and key indicators fail to meet the measurement requirements. In terms of bus-based high-precision temperature measuring instruments, there is also a big gap in my country.

Overall design 2.1 Overall system plan
The goal of this project is to design a temperature sensor experimental instrument. The lower computer adopts STM32F103 single-chip microcomputer for programming. The thermal resistance temperature sensor collects the temperature signal, sets it through the signal conditioning circuit, and then uses the STM32 single-chip microcomputer for A/D conversion, and sends the converted digital signal to the single-chip microcomputer. The K-type thermocouple is connected to the MAX6675 module, and the signal amplification, cold junction compensation, and A/D conversion are performed through the MAX6675 module. The STM32 microcontroller reads the converted temperature data through the SPI serial port, and finally sends the data to the host computer through the Wifi module. So that the host computer can display, alarm, remote view and other functions of the temperature data of the thermocouple and the thermal resistance temperature sensor. The overall block diagram of the system is shown in Figure  The hardware part of the temperature sensor experimental instrument mainly includes the minimum system circuit of the single-chip microcomputer, the thermistor sensor module, the K-type thermocouple, the MAX6675 module, the key circuit, the ESP8266Wifi module, and the digital tube display circuit.

The minimum system of single chip microcomputer
The minimum system circuit of the single-chip microcomputer is composed of STM32F103VCT6 chip, crystal oscillator and reset circuit.
Crystal oscillator circuit: The minimum system of the single-chip microcomputer uses an external 8M crystal oscillator, which provides a 72M system clock for the MCU after 9 times the frequency within the chip. The 32.768KHZ crystal oscillator is a low-speed real-time clock provided when using the on-chip RTC.
Reset circuit: The reset circuit mainly utilizes the property that capacitance and voltage will not change suddenly. After the power is turned on, the voltage on the capacitor is zero, the chip is reset, and then the power is charged to C3 through R1 until the capacitor voltage rises to a high level, and the chip starts to work.

Thermistor sensor module
This design uses NTC thermistor sensor module to measure the temperature of the measured environment. The blue digital potentiometer in the picture can adjust the sensitivity of the module. The working voltage range of this module is 3.3V-5V. Therefore, the pin VCC terminal can be directly connected to the 3.3V or 5V MCU, the pin GND terminal can be connected to the MCU GND terminal, and the pin A0 is an analog output interface, which can be directly connected to the A/D conversion module of the MCU.

K-type thermocouple
This design uses a K-type thermocouple to measure the temperature. The device has a wide measuring temperature range, low price and good sensitivity, and it has been widely used in industrial field measurement. The temperature compensation of the cold junction is required for this component when measuring the temperature. The cold junction temperature compensation includes freezing point method, compensation bridge method and calculation correction method. The red end is the working end, and the blue end is the free end.

MAX6675 module
This design uses the MAX6675 module. The module set can amplify the thermoelectromotive force signal collected by the thermocouple and can perform cold junction compensation. Then convert the analog signal into a digital signal through A/D conversion. Finally, the STM32 microcontroller reads the temperature measurement data through the SPI serial port.

ESP8266Wifi module
According to the requirements of this design, the collected temperature data needs to be uploaded to the host computer. So this design uses ESP8266Wifi module to realize the connection with OneNet platform. The design of the temperature sensor experimental instrument adopts EDP protocol for data transmission.
ESP8266Wifi module uses 3.3V power supply. Therefore, the VCC terminal is connected to the MCU +3.3V terminal for power supply. GND is connected to the GND end of the single-chip microcomputer, TX of the Wifi module is connected to the serial port 2 receiving pin PA3 of the single-chip microcomputer, and RX is connected to the serial port 2 sending pin PA2 of the single-chip microcomputer.

System software design 4.1 Overall software design
In the design of the temperature sensor experimental instrument, the software part mainly includes the thermistor module acquisition subroutine, MAX6675 temperature measurement data acquisition subroutine, digital tube display subroutine, independent button subroutine, ESP8266Wifi module subroutine.
In the main program flow chart, the first tasks to be completed are the initialization of the digital tube, serial port, timer, ADC, button, ESP8266Wifi and other modules. The second is to complete the system functions. The design idea of this program is to enter a thermistor module temperature measurement data reading at 200ms regularly to detect whether the temperature exceeds the upper and lower limits. At the same time, the conversion time of the temperature signal measured by the MAX6675 to the K-type thermocouple is about 0.2s, so the delay time is set to 0.2s, and the collected temperature data is uploaded to the OneNet platform. Finally, call the key function to perform the corresponding function of pressing the key.

Thermistor sensor subprogram design
A thermistor converts a change in resistance to a change in temperature. The temperature data collected by thermistor sensor is not calculated directly, but the resistance value at different temperature T is calculated in advance. The voltage value is collected by ADC and converted into resistance value. The resistance value is converted to temperature by looking up table.

K-type thermocouple subprogram design
In this design, the K-type thermocouple is connected to the MAX6675 module. The module can perform a series of processing on the temperature signal collected by the K-type thermocouple, and finally converts the analog signal to a digital signal output through the A/D converter in the module. Therefore, use the SPI1 serial port to communicate with the STM32 microcontroller and read the data obtained by the MAX6675. And print the read data to serial assistant through serial port 1.

ESP8266Wifi module subprogram design
The main function of the ESP8266Wifi module is to upload the collected temperature data to the OneNet platform. In this design, the STM32 microcontroller communicates with the Wifi module via serial port 2. Configure the Wifi module through AT commands and connect to the hotspot. Wifi module and OneNet cloud platform adopt EDP protocol.

System debugging 5.1 Comprehensive debugging of system modules 1) Digital tube, thermistor sensor and Wifi module debugging
In this design, the NTC thermistor sensor is used to collect the temperature of the measured object. The thermistor sensor collects the temperature, and then obtains the current temperature through A/D conversion and table look-up processing, and displays it on the digital tube. At the same time, upload the collected temperature value to the OneNet platform through the Wifi module for display. Figure  5.1 is the digital tube temperature display interface, and Figure 5.2 is the OneNet platform temperature display interface.  (1) 2) K-type thermocouple, MAX6675 module, SPI1 serial port and Wifi module debugging In this design, a K-type thermocouple is also used to collect the current ambient temperature. However, the temperature signal collected by the K-type thermocouple needs to be further processed, and there are problems such as the nonlinearity of the thermoelectromotive force and temperature, the need for cold junction compensation, and the need for A/D conversion. In this way, it brings great trouble to the design and programming this time. Therefore, this design uses the MAX6675 module. This module can solve the above problems, and can communicate with the STM32 microcontroller through the SPI serial port. Therefore, in programming, you only need to read the temperature measurement data after MAX6675 module conversion processing through the SPI serial port. When programming, you can write the Printf() function to print the data of the current program's reply on the serial assistant, which can display the temperature value measured by the K-type thermocouple. As shown in Figure 5.3. At the same time, through the Wifi module, the measured temperature value is uploaded to the OneNet platform for real-time display. As shown in Figure 5.4.  (2) 5.2 Overall system debugging 1) Download the program to the STM32 microcontroller. At this time, the digital tube displays the temperature value collected by the thermistor sensor. Pinch the thermistor by hand, you can find the temperature value on the digital tube rises. Similarly, hold the temperature probe of the K-type thermocouple, and then open the serial port assistant, you can observe that the temperature value measured by the thermocouple will rise. When the temperature value is higher than the set upper temperature limit or lower than the lower temperature limit, the buzzer alarms. When the measured temperature value is between the upper and lower limits, the buzzer stops alarming.
2) Press the key Key1, the temperature interface switches to the temperature upper and lower limit setting interface. This interface can set the lower temperature limit. Each time the key Key2 is pressed, the set value increases by 1. Each time the key Key3 is pressed, the set value decreases by 1. Press the Key1 key again, then you can set the upper temperature limit. The setting method is the same as above. Press the key Key4 to return to the temperature display interface.
3) Log in to the OneNet platform and view the application. Observe whether the received temperature value is consistent with the data displayed by the digital tube and serial port assistant. At the same time, you can click on the data stream to view historical data