CN-121994368-A - Singlechip temperature detection method, device and equipment
Abstract
The application relates to a temperature detection method, a device and equipment of a singlechip, and the method comprises the steps of carrying out polling counting in a pulse group window and synchronously measuring corresponding actual execution time based on a specific time sequence structure output by a temperature sensor, obtaining an original count value and window actual measurement time, generating accurate equivalent signal unit quantity according to the original count value and the window actual measurement time by combining a theoretical period of a signal unit through a reference time and a proportional conversion model, and generating a temperature physical quantity according to the equivalent signal unit quantity by a linear conversion formula and a segmentation correction algorithm provided by the sensor. According to the application, the original count is converted into the accurate pulse number by adopting a pure polling and proportional conversion model in a timer-free environment, and the temperature measurement is realized on a low-cost MCU by combining the piecewise compensation.
Inventors
- LI XI
- LUAN GUOCHEN
Assignees
- 北京睿智奥恒视觉科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260121
Claims (10)
- 1. The temperature detection method of the singlechip is characterized by comprising the following steps of: Based on a specific time sequence structure output by the temperature sensor, acquiring an original count value and window actual measurement time by carrying out polling counting in a pulse group window and synchronously measuring corresponding actual execution time; According to the original count value and the window actual measurement time, the theoretical period of the signal units is combined through a reference time length and a proportional conversion model, and the accurate equivalent signal unit number is generated; And generating the temperature physical quantity according to the number of equivalent signal units through a linear conversion formula and a piecewise correction algorithm provided by the sensor.
- 2. The method for detecting the temperature of the single chip microcomputer according to claim 1, wherein the specific time sequence structure based on the output of the temperature sensor obtains an original count value and a window actual measurement time by performing polling counting in a pulse group window and synchronously measuring a corresponding actual execution time length, and the method comprises the following steps: triggering the sampling entering the pulse communication period by detecting the GPIO level jump according to the falling edge signal of the data conversion period output by the temperature sensor; In the pulse communication period, recording the occurrence times of low level by continuously polling the level state of GPIO to obtain an original count value; the synchronization marks the execution interval of the count code by controlling one auxiliary GPIO to output a high level, and measures the duration of the high level by using an oscilloscope to acquire window actual measurement time.
- 3. The single chip microcomputer temperature detection according to claim 1, wherein the generating of the accurate equivalent signal unit number by combining the theoretical period of the signal unit by the reference time length and the scaling model according to the original count value and the window actual measurement time comprises: according to the window actual measurement time obtained by the first calibration measurement and the original count value, calculating the ratio to obtain the average time corresponding to the single count; And converting the new original count value into the number of equivalent signal units through a proportional conversion formula according to the average time and the theoretical period of the signal units.
- 4. The singlechip temperature detection method according to claim 1, wherein the generating the temperature physical quantity according to the number of equivalent signal units by using a linear conversion formula and a piecewise correction algorithm provided by a sensor comprises: Calculating a preliminary temperature value through a linear conversion formula according to the number of equivalent signal units; according to the temperature interval where the preliminary temperature value is located, nonlinear compensation is carried out through a segmentation correction algorithm, the temperature physical quantity is obtained, and the accuracy meets the application requirements of judging the temperature threshold value or monitoring the change trend under the resource constraint condition that a hardware timer and external interruption cannot be started.
- 5. The temperature detection of a single chip microcomputer according to claim 2, wherein the step of recording the number of occurrences of the low level by continuously polling the level state of the GPIO during the pulse communication period to obtain the original count value comprises the steps of: According to the time sequence characteristic that the temperature sensor outputs periodic short pulses in a pulse communication period, on the premise that a hardware timer cannot be started and external interruption is not possible, continuously polling and detecting GPIO level of a sensor data pin at the highest frequency which can be achieved by the main cycle of the singlechip; and (3) recording each captured low-level event by judging whether the GPIO level is low, and accumulating to obtain an original count value.
- 6. The singlechip temperature detection method according to claim 3, wherein the converting the new original count value into the number of equivalent signal units according to the average time and the theoretical period of the signal units by a scaling formula comprises: According to the window actual measurement time obtained in the first calibration measurement and the corresponding original count value, calculating and obtaining the average time consumed by the single chip microcomputer for executing one counting cycle; based on the average time and the known theoretical period of the signal unit, converting a new original count value obtained by each subsequent measurement into an accurate equivalent pulse number through a core proportional conversion formula; the core proportion conversion formula sets the window actual measurement time as The original count value is The new original count value obtained by measurement is The equivalent pulse number is The theoretical period of the signal unit is The core scaling formula is: 。
- 7. The method for detecting the temperature of the singlechip as set forth in claim 4, wherein the nonlinear compensation is performed by a piecewise correction algorithm according to a temperature interval in which the preliminary temperature value is located to obtain a temperature physical quantity, and the accuracy of the temperature physical quantity meets the application requirements for determining a temperature threshold or monitoring a change trend under the resource constraint condition that a hardware timer and external interrupt cannot be started, the method comprises: judging the temperature interval according to the preliminary temperature value obtained by calculating the pulse number through a linear formula; The linear formula sets the equivalent pulse quantity as The preliminary temperature value is Linear conversion coefficient of And The linear formula is: ; According to the judgment result, nonlinear compensation is carried out by applying a subsection temperature correction algorithm provided by a sensor, and a final temperature value is obtained; The correction algorithm sets a final temperature value The preliminary temperature value is The interval boundary value is And The compensation coefficient is And The specific compensation is as follows: When (when) When using the formula Compensating; When (when) When using the formula ; When (when) When using the formula And compensating.
- 8. The utility model provides a singlechip temperature monitoring device which characterized in that, the device includes: the indirect pulse measurement module is used for acquiring an original count value and window actual measurement time by carrying out polling counting in a pulse group window and synchronously measuring corresponding actual execution time based on a specific time sequence structure output by the temperature sensor; The proportional conversion modeling module is used for generating accurate equivalent signal unit quantity by combining the theoretical period of the signal units through the reference time length and the proportional conversion model according to the original count value and the window actual measurement time; And the nonlinear compensation module is used for generating temperature physical quantity according to the number of equivalent signal units through a linear conversion formula and a piecewise correction algorithm provided by the sensor.
- 9. The single-chip microcomputer temperature detection device according to claim 8, wherein the scaling modeling module further comprises: And the reference parameter calibration module is used for establishing an average time-consuming reference for the system to execute single counting operation according to the ratio of the window actual measurement time to the original counting value in the first measurement. And the proportional model construction module is used for combining the average time consumption reference of the single counting operation with the theoretical period of the signal unit to construct a proportional conversion relation between the original count value and the number of equivalent signal units. The pulse number conversion module is used for converting the original count value obtained by subsequent measurement into the accurate equivalent signal unit number based on the constructed proportional conversion relation.
- 10. An electronic device, comprising: The processor is used for executing all calculation tasks and realizing the functions of time sequence detection, polling counting, proportion conversion and temperature calculation in the singlechip temperature detection method; And the memory is used for storing the processor executable instructions, the calibration parameters and the temperature conversion formula.
Description
Singlechip temperature detection method, device and equipment Technical Field The present application relates to the field of embedded systems, and in particular, to a method, an apparatus, and a device for detecting a temperature of a single chip microcomputer. Background Temperature measurement has wide and critical application requirements in various fields such as industrial control, environmental monitoring, medical equipment, consumer electronics and the like. With the development of miniaturization and low power consumption of the internet of things and embedded devices, how to realize stable and reliable temperature sensing on a low-cost Microcontroller (MCU) with limited resources has become one of the key challenges of improving the performance of the devices and reducing the cost. Traditional temperature measurement schemes, either relying on analog sensors with built-in ADCs and complex calibration algorithms, or requiring MCUs with high-speed timer/interrupt resources to directly capture the output of the digital pulse sensor, undoubtedly increase the hardware threshold and overall cost of the system. Currently, in dealing with digital pulse temperature sensors based on a single bus or a specific timing protocol, such as DS18B20, NST1001, common implementations rely primarily on a hardware timer or external interrupt function of the microcontroller to accurately capture the edges of each pulse. However, in a large number of low-cost, low-power-consumption general-purpose MCUs, hardware timer resources may be extremely limited or other critical functions need to be served, and application scenarios where interrupts are prohibited to ensure timing stringency are also common. Under the condition of such resource limitation, if the pulse is directly read by adopting a simple GPIO polling mode, microsecond-level narrow pulses output by a sensor are extremely easy to miss due to execution delay of a polling cycle and scheduling uncertainty of a processor, so that serious distortion of pulse count is caused, and finally, a temperature measurement result has huge error or even is completely invalid. Therefore, there is an urgent need for an innovative method that is independent of a dedicated hardware timing unit, and that can implement pulse counting and temperature resolution under a pure software polling framework. In the prior art, temperature measurement for resource-constrained environments often compromises accuracy, reliability and cost. Either an analog scheme with lower precision and complex nonlinear compensation is adopted, or a special pulse counting and timing auxiliary chip is additionally arranged on the digital sensor, which increases the complexity of the system and the material cost. How to realize digital pulse type temperature measurement against system delay on the basis of common GPIO polling only by optimizing a software algorithm on the premise of not increasing extra hardware cost and not occupying scarce timer/interrupt resources is a technical problem to be solved in the field. Disclosure of Invention Based on the above, the application provides a singlechip temperature detection method, which comprises the following steps: Based on a specific time sequence structure output by the temperature sensor, acquiring an original count value and window actual measurement time by carrying out polling counting in a pulse group window and synchronously measuring corresponding actual execution time; According to the original count value and the window actual measurement time, the theoretical period of the signal units is combined through a reference time length and a proportional conversion model, and the accurate equivalent signal unit number is generated; And generating the temperature physical quantity according to the number of equivalent signal units through a linear conversion formula and a piecewise correction algorithm provided by the sensor. Optionally, the obtaining the original count value and the window actual measurement time based on the specific time sequence structure output by the temperature sensor by performing polling counting in the pulse group window and synchronously measuring the corresponding actual execution time includes: triggering the sampling entering the pulse communication period by detecting the GPIO level jump according to the falling edge signal of the data conversion period output by the temperature sensor; In the pulse communication period, recording the occurrence times of low level by continuously polling the level state of GPIO to obtain an original count value; the synchronization marks the execution interval of the count code by controlling one auxiliary GPIO to output a high level, and measures the duration of the high level by using an oscilloscope to acquire window actual measurement time. Optionally, the generating the accurate equivalent signal unit number by combining the theoretical period of the signal unit according to the original coun