Disclosure of Invention
In order to solve the above problems, the present invention provides a temperature detection apparatus and a temperature detection method, which are used to unify NTC thermistor and PT100 resistor sampling circuits and implement automatic identification and temperature detection of two types of temperature sensors.
According to an aspect of the present invention, there is provided a temperature detection apparatus including:
a first resistor connected to a reference power supply;
the second resistor is connected with the first resistor in series and is connected with the thermistor to be tested in parallel;
the control module is used for acquiring voltage signals of two parallel ends of the second resistor and the thermistor and two ends of the first resistor, calculating the resistance value of the thermistor based on the voltage signals, and acquiring the temperature to be measured based on the calculated resistance value of the thermistor.
According to one embodiment of the invention, the thermistors include a PT100 resistor and an NTC thermistor.
According to an embodiment of the invention, a filter capacitor is further connected in parallel to two ends of the second resistor and the thermistor, and is used for filtering the voltage signal input to the control module.
According to one embodiment of the invention, the control module comprises:
the first sampling circuit is used for sampling the voltage at two ends of the first resistor;
the second sampling circuit is used for sampling the voltages at two ends of the parallel connection part of the second resistor, the thermistor and the filter capacitor;
and the resistance value calculation circuit calculates the proportion of the parallel resistance values of the thermistor and the second resistor to the resistance value of the first resistor based on the voltage signals output by the first sampling circuit and the second sampling circuit, and calculates the resistance value of the thermistor based on the resistance values of the first resistor and the second resistor.
According to an embodiment of the invention, the control module further comprises a judging circuit connected with the resistance value calculating circuit, and the judging circuit is used for distinguishing the types of the thermistors and detecting whether the circuit is short-circuited or not based on the resistance value output by the resistance value calculating circuit.
According to an embodiment of the present invention, the judgment circuit distinguishes the kind of the thermistor based on the resistance value range across the parallel portion of the second resistor, the thermistor, and the filter capacitor, wherein,
when the resistance value calculated by the resistance value calculating circuit is less thanWhen the thermistor is used, the thermistor is a PT100 resistor;
when the resistance value calculated by the resistance value calculating circuit is larger thanWhen in use, the thermistor is an NTC thermistor,
wherein, b1Is the maximum value of the resistance range of the PT100 resistor in a temperature variation range, a2Is the minimum value of the resistance value range of the NTC thermistor in the same temperature variation range, a2>b1,R2Is the resistance of the second resistor.
According to an embodiment of the present invention, the control module further includes a first resistance-temperature conversion module connected to the determination circuit, and configured to perform resistance and temperature conversion on the PT100 resistor by using a conversion equation:
wherein R isPT100The resistance value of the PT100 resistor and the temperature to be detected are T.
According to an embodiment of the invention, the control module further includes a second resistance-temperature conversion module connected to the determination circuit, and configured to perform resistance and temperature conversion on the NTC thermistor through a table lookup manner.
According to another aspect of the present invention, there is also provided a temperature detection method for the temperature detection device of any one of the above, including:
acquiring the resistance values of the first resistor and the second resistor;
reading voltage signals at two ends of the first resistor and voltage signals at two ends of the second resistor and the thermistor which are connected in parallel;
calculating the resistance value of the thermistor based on the voltage signals at the two ends of the first resistor, the voltage signals at the two ends of the second resistor and the thermistor in parallel connection, and the resistance values of the first resistor and the second resistor;
and acquiring the temperature to be detected based on the calculated resistance value of the thermistor.
According to an embodiment of the present invention, the step of obtaining the temperature to be detected based on the calculated resistance value of the thermistor further includes:
judging the type of the thermistor, and when the calculated resistance value is less thanWhen the resistance value is greater than the calculated resistance value, the thermistor is a PT100 resistorWhile, the thermistorIs an NTC thermistor, wherein b1Is the maximum value of the resistance range of the PT100 resistor in a temperature variation range, a2Is the minimum value of the resistance value range of the NTC thermistor in the same temperature variation range, a2>b1,R2Is the resistance value of the second resistor;
when the thermistor is a PT100 resistor, the resistance value is converted into the temperature through a conversion formula, wherein the conversion formula is as follows:
wherein R is2Is the resistance of the PT100 resistor, T is the temperature;
and when the thermistor is an NTC thermistor, converting the resistance value into the temperature in a table look-up mode.
The invention has the beneficial effects that:
the resistance value of the thermistor can be calculated based on the ratio of the resistance values of the circuits where the first resistor and the second resistor are located and brought into the corresponding resistance values, the temperature to be measured is calculated, the resistance value of the temperature sensor can be limited within the detection range of the control module through the parallel resistors, the NTC thermistor and the PT100 resistor can be compatible, the circuit design is simplified, the board distribution space is saved, the processing software is compatible, and meanwhile, the short circuit detection function is achieved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Detailed Description
The following detailed description of the embodiments of the present invention will be provided with reference to the drawings and examples, so that how to apply the technical means to solve the technical problems and achieve the technical effects can be fully understood and implemented. It should be noted that, as long as there is no conflict, the embodiments and the features of the embodiments of the present invention may be combined with each other, and the technical solutions formed are within the scope of the present invention.
Different motors may use different types of temperature sensors, and the difference causes the types of temperature detection circuits to increase, the state of the system to increase, and the control on the product quality and the cost is not facilitated. Two commonly used temperature sensors are respectively made of an NTC thermistor and a PT100 resistor, and the temperature sensors made of the two resistors have different detection principles.
FIG. 1 is a schematic diagram of a conventional NTC thermistor sampling circuit, in which the NTC thermistor is connected with a constant voltage sourceAnd sampling in a voltage division mode. High-precision constant voltage source VrefThe voltage is divided by a precise fixed resistor R and an NTC thermistor, the divided voltage value is sent to an AD sampling port of an MCU (micro control unit) for sampling, then the corresponding resistance value of the NTC thermistor is calculated by the MCU, and the temperature detection is realized by checking an R-T table of the NTC thermistor.
Fig. 2 shows a general PT100 resistor sampling circuit topology, in which a constant current source generates a voltage signal through a PT100 resistor and sends the voltage signal to an AD sampling port of an MCU for sampling, and then the MCU calculates a resistance value R of the PT100 resistor, and calculates a corresponding temperature value through a formula of (R-100)/0.385.
For the sampling circuit of the NTC thermistor, the voltage variation range of the NTC thermistor in the whole temperature range is generally as large as possible, and the analog quantity AD sampling port of the MCU samples in full scale, so as to improve the accuracy of the temperature detection circuit. The resistance variation range of the NTC thermistor is generally several tens kilo-ohms to several hundreds ohms, and the resistance variation range of the PT100 resistor is several tens ohms to several hundreds ohms, so the NTC thermistor sampling circuit cannot be applied to sampling of the PT100 resistor because the voltage variation range detected by the AD sampling port is too small and is not reasonable in design. Example (c): the resistance of a certain model PT100 is linearly changed from 100 omega to 177 omega (corresponding to 0 ℃ to 200 ℃). NTC thermistors (R (25 ℃), 30k Ω) vary nonlinearly from 97.663k Ω to 0.191k Ω (corresponding to 0 ℃ to 200 ℃). If a 5V standard is adopted, and the reference resistor R is 2k omega, the sampling voltage range of the sampling circuit of the NTC thermistor is 0-200 ℃ as follows: 0.1V-4.564V, and the MCU analog quantity AD sampling port is full-scale sampling. The sampling circuit of PT100 resistance samples the voltage range and is: 4.7619V-4.5935V, namely the sampling voltage variation range in the whole temperature range is only 0.1684V, which is far less than the range (5V) of the analog quantity AD sampling port, and the design is unreasonable.
For a PT100 resistance sampling circuit, the value obtained by multiplying the maximum value of the PT100 resistance in a temperature range by a constant current source is generally equal to or slightly smaller than the sampling maximum value of an MCU analog quantity sampling port. Because the resistance range of the NTC thermistor is far larger than that of the PT100 resistor, the NTC thermistor cannot be sampled by using a constant current source.
The two temperature detection circuits need to generate a constant voltage source or a constant current source, the higher the precision of the constant voltage source or the constant current source is, the more accurate the sampling temperature is, and meanwhile, the higher the cost of the circuit is. The two sampling circuits have no universality for different types of temperature sensors. The difference between the two circuits will lead to the increase of the types of the circuit boards, which is not beneficial to the system type and management of the product.
Therefore, the invention provides a temperature detection circuit which is used for unifying the NTC thermistor and the PT100 resistance sampling circuit and realizing automatic identification and detection of two temperature sensors. Fig. 3 is a schematic diagram of a temperature detection circuit according to an embodiment of the present invention, and the present invention will be described in detail with reference to fig. 3.
The temperature detection device comprises a first resistor R1, a second resistor R2 and a control module, wherein the first resistor R1 is connected with a reference power supply Vref. The second resistor R2 is connected in series with the first resistor R1 and is also connected in parallel with a thermistor R0 for sensing temperature. The control module collects voltage signals at two ends of the second resistor R2 and the thermistor R0 and at two ends of the first resistor R1, calculates the resistance value of the thermistor based on the collected voltage signals, and obtains the temperature to be measured based on the calculated resistance value of the thermistor.
In the invention, the thermistor R0 to be tested is connected with the second resistor R2 in parallel, and the resistance value after the parallel connection is smaller than R2, so that the voltage at two ends of the thermistor R0 is limited. For example, when the temperature is in the range of 0 ℃ to 200 ℃, the resistance value of the PT100 resistor is in the range of 100 Ω to 177 Ω, and after the PT100 resistor is connected with R3 with proper resistance value in parallel, the resistance value after the PT100 resistor is connected in parallel is not changed greatly. The resistance range of the NTC thermistor is 97.663 kOmega-0.191 kOmega, the voltage at the two ends of the NTC thermistor can be limited to R2 by connecting a second resistor R2 at the two ends of the NTC thermistor in parallel, and the voltage range at the two ends of the NTC thermistor can be close to the resistance range of the PT100 resistor by adjusting the value of the second resistor R2. Therefore, by matching the value of the second resistor R2, the temperature detection device can measure the PT100 resistor and the NTC thermistor with different resistance ranges and larger resistance range difference, so that the sampling circuits of the two thermistors are unified, the manufacturing cost is saved, the layout of a circuit board is facilitated, and the reliability of the circuit is improved.
In one embodiment of the present invention, a coupling capacitor C3 is connected in parallel between the second resistor R2 and the thermistor R0 for filtering the voltage signal input to the control module.
In one embodiment of the invention, the control module comprises a first sampling circuit, a second sampling circuit and a resistance value calculation circuit. The first sampling circuit is used for sampling the voltage at two ends of the first resistor R1; the second sampling circuit is used for sampling the voltage at two ends of the parallel connection part of the second resistor R2, the thermistor R0 and the filter capacitor C3; and the resistance value calculation circuit calculates the proportion of the parallel resistance value of the thermistor and the second resistor to the resistance value of the first resistor based on the voltage signals output by the first sampling circuit and the second sampling circuit, and calculates the resistance value of the thermistor based on the resistance values of the first resistor and the second resistor.
Specifically, the first sampling circuit is connected in parallel with the first resistor R1, and the voltage at two ends of the R1 is acquired as U1. The second sampling circuit is connected in parallel with the second resistor R2, the thermistor R0 and the filter capacitor C3, and the voltage at two ends in parallel is acquired to be U2. Based on U1/R1 ═ U2/(R0// R2), since U1 and U2 can be accurately calculated through sampling, R2 can be accurately sampled through a circuit when the R0 is not connected or can be directly measured through a precision multimeter, and R1 can be measured through the precision multimeter, the value R0 of the temperature sensor can be calculated.
In one embodiment of the invention, the control module further comprises a judging circuit connected with the resistance value calculating circuit, and the judging circuit is used for distinguishing the types of the thermistors and detecting whether the circuit is short-circuited or not based on the resistance value output by the resistance value calculating circuit. Specifically, the judgment circuit distinguishes the thermistors based on the resistance ranges of the two ends of the parallel connection part of the second resistor R2, the thermistor R0 and the filter capacitor CThe type of resistor R0. Setting (a)1,b1) Is the resistance range of PT100 resistor, b1Is the maximum value of the resistance range of the PT100 resistor in a temperature variation range, (a)2,b2) Is the resistance range of the NTC thermistor, a2Is the minimum value in the resistance value range of the NTC thermistor in the same temperature variation range, and a2>b1The resistance value ranges of the two resistors are explained to have no overlapping area in the set temperature range.
Due to a2>b1,a2The value of// R2 is greater than b2// R2, the parallel value of any resistance value in the resistance value range of the PT100 resistor and R2 is less than or equal to b2The value of// R2, the parallel value of any resistance value in the range of the resistance values of the NTC thermistor and R2 is more than or equal to a2The value of// R2. From the above analysis, when the resistance calculated by the resistance calculating circuit is smaller thanWhen the thermistor is used, the thermistor is a PT100 resistor; when the resistance value calculated by the resistance value calculating circuit is larger thanWhen the thermistor is an NTC thermistor.
From the above analysis, it can be seen that different types of thermistors can be distinguished as long as the resistance value of the thermistor in a certain temperature range includes a non-overlapping region.
In addition, when the resistance values of two ends of the parallel connection part of the second resistor R2, the thermistor R0 and the filter capacitor C calculated by the resistance value calculation circuit are close to 0, the detection circuit can be judged to be short-circuited.
Since the PT100 resistor and the NTC thermistor perform resistance and temperature conversion by different methods, in an embodiment of the present invention, the control module further includes a first resistance-temperature conversion module connected to the determination circuit, for performing resistance and temperature conversion on the PT100 resistor by a conversion formula, where the conversion formula is:
wherein R isPT100The resistance value of the PT100 resistor and the temperature to be detected are T.
The control module also comprises a second resistance-temperature conversion module connected with the judgment circuit and used for performing resistance and temperature conversion on the NTC thermistor in a table look-up manner.
According to another aspect of the present invention, there is also provided a temperature detection method using the above temperature detection apparatus, as shown in fig. 4, the method including the following steps.
First, in step S110, the resistances of the first resistor R1 and the second resistor R2 are obtained. Next, in step S120, a reference power is introduced into the device, and the voltage signal across the first resistor R1 and the voltage signal across the parallel connection of the second resistor R2 and the thermistor R0 are read. Then, in step S130, the resistance value of the thermistor is calculated based on the voltage signal across the first resistor R1, the voltage signal across the parallel connection of the second resistor R2 and the thermistor R0, and the resistance values of the first resistor R1 and the second resistor R2. Finally, in step S140, the temperature to be measured is obtained based on the calculated resistance value of the thermistor.
In an embodiment of the present invention, the step of obtaining the temperature to be detected based on the calculated resistance value of the thermistor further includes the steps of determining the type of the thermistor and obtaining the temperature to be detected in different manners based on different types of thermistors.
In the step of judging the type of the thermistor, when the calculated resistance value is less thanWhen the thermistor R0 is PT100 resistor, the calculated resistance is larger thanThen, the thermistor R0 is an NTC thermistor, wherein (a)1,b1) Is the resistance range of the PT100 resistor in a temperature variation range, b1Is the maximum value of the resistance range of the PT100 resistor in a temperature variation range, (a)2,b2) Is the resistance range of the NTC thermistor in the same temperature variation range, a2Is the minimum value of the resistance value range of the NTC thermistor in the same temperature variation range, a2>b1,R2Is the resistance value of the second resistor; when the thermistor is a PT100 resistor, the resistance value is converted into the temperature by the conversion formula (1). When the thermistor is an NTC thermistor, the resistance value is converted into the temperature by a table look-up mode.
Fig. 5 is a schematic circuit diagram of a MAX31865 chip as a sampling circuit according to an embodiment of the present invention. The MAX31865 chip can sample the PT100 resistor or the PT1000 resistor, and the detection range of the MAX31865 chip is adjusted by selecting the resistance value of the peripheral resistor R1. The resistor R1 needs to be larger than the parallel value of R0 and R2 between the detection ports. In the invention, the resistance of a certain type PT100 is linearly changed from 100 omega to 177 omega (corresponding to 0-200 ℃). NTC thermistors (R (25 ℃), 30k Ω) vary nonlinearly from 97.663k Ω to 0.191k Ω (corresponding to 0 ℃ to 200 ℃), and have a resistance value range of 95 Ω to 1919.7 Ω (0 ℃ to 200 ℃) in parallel with R3, so the values of R2 were selected to be 3k Ω, 0.1W, and 0.1% accuracy, 10 ppm. The test precision of the MAX31865 chip is 0.5 ℃, and the detection precision of the resistance is higher than 0.1% through the test. The input signal is properly filtered by adding a capacitor C3 depending on the engineering application.
The MAX31865 chip adopts 3.3V direct current power supply for power supply, a 0.1uF capacitor is added to each power port for decoupling, the chip exchanges data with the control chip through the serial communication interface, and/DRDY is a data conversion state signal, namely a state signal indicating whether temperature acquisition and conversion of the MAX31865 chip are completed or not. R2 is 2k omega, 0.1W, precision is 0.1%, 10ppm resistance. Hereinafter, errors in the detection of the PT100 resistor and the NTC thermistor are analyzed. Based on sampling circuits with different voltage references, values of the first resistor R1 and the second resistor R2 can be flexibly selected.
When the MAX31865 chip is used as a sampling circuit, R0 is disconnected, and the resistance value of R2 is detected by a precision multimeter and is solidified into a data processing program of a control module, so that subsequent circuit calculation is facilitated. The precision multimeter is 6-bit and half-precision, the resistance of 2k omega is measured, namely the precision is 0.01 omega, the temperature corresponding to the resistance converted into PT100 is 0.03 ℃, and the resistance value of R2 can be ignored, namely the resistance value is considered to be precise.
The PT100 resistance value is linear change of 100 omega-177 omega (corresponding to 0-200 ℃). The range of resistance through parallel connection with R2 is:the accuracy of the detection circuit is 0.1%, namely the error is equal to 0.177 omega, and the total error is less than 0.2 omega, namely 0.52 ℃ by adding the error of R2. The sampling precision of the PT100 resistor can meet the requirement within +/-1 ℃ by considering the extremely low temperature drift of the resistor and the chip. And the requirements of engineering application are met.
The resistance value of the NTC thermistor is 97.663k omega-0.191 k omega (corresponding to 0 ℃ -200 ℃) and changes nonlinearly. The range of resistance through parallel connection with R3 is:the accuracy of the detection circuit is 0.1%, namely less than 2 Ω, and the total error is less than 2 Ω by adding the error of R2. For convenience of explanation, circuit calculations and analyses were performed with R2 ═ 2.002k Ω: if the resistance difference between the NTC thermistor and the R2 after being connected in parallel is greater than 2 omega every time the temperature rises by 1 ℃, the detection accuracy of the circuit can be considered to be higher than 1 ℃, and the parallel connection value of the NTC thermistor and the R2 under different temperature conditions is calculated as shown in the following table 1.
The resistance difference formula is: Δ R ═ Rt-5-Rt,RtThe resistance value of the NTC thermistor is connected with R2 in parallel at the temperature t. For convenience of explanation, the temperature change of the NTC thermistor in the 5 ℃ interval can be regarded as a linear change approximately, and if the temperature rises by 5 ℃, the difference between the resistance values of the NTC thermistor and R2 connected in parallel can be obtainedIf the resistance value is more than 10 omega, the detection accuracy of the circuit is considered to be the same as that of 1 ℃ except that the change of the resistance value is less than 10 omega when the temperature is between 0 ℃ and 5 ℃, namely the error is more than 1 ℃ and less than 2 ℃, and the change of the resistance value is more than 10 omega when the temperature detected by the NTC is increased by 5 ℃ at other temperatures, so that the detection accuracy of the circuit is more than +/-2 ℃ in the range of 0-200 ℃, and the engineering application requirements are completely met.
TABLE 1
The MAX31865 chip is initialized, and a protection limit value, an operation mode and the like are set based on the type of the thermistor R0. Reading a parallel value R4 of R2 and R0(PT100 resistor or NTC thermistor) by a MAX31865 chip, if R4 is less than 162 omega, judging that the detected temperature sensor is the PT100 resistor, calculating the resistance value of R0 by a control module, and calculating a corresponding temperature value by a calculation formula (1); if R4 is greater than 174 Ω, it can be determined that the detected temperature sensor is an NTC thermistor, the resistance value of R0 is calculated, and then the corresponding temperature value is read by looking up the R-T table of the NTC thermistor. Considering the influence of the control module and the resistance of other lines, if R4 is approximately equal to 0 ± 10 Ω, it can be determined that the detection circuit is short-circuited.
Although the embodiments of the present invention have been described above, the above description is only for the convenience of understanding the present invention, and is not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.