Pulse signal acquisition method and device
By combining data collection with an acquisition cycle timer based on interrupt wake-up, the problems of high power consumption and poor anti-interference ability of industrial Internet of Things data collection equipment in extreme environments are solved, and low-power and high-stability data collection is achieved.
Patent Information
- Application Number
- CN202510850422.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-09-16
AI Technical Summary
Existing industrial Internet of Things data acquisition equipment has high power consumption and poor anti-interference ability in extremely harsh environments, resulting in inaccurate collection accuracy.
Data collection is performed by combining interrupt wake-up with collection cycle timer. The device is woken up by judging the interrupt signal, and the collection cycle timer is started and woken up at the preset time for data collection. The power consumption is reduced in the sleep state, and the anti-interference ability is improved through dual interruption.
It reduces the power consumption of the acquisition equipment, improves the acquisition stability and anti-interference ability, ensures the accuracy of data acquisition, and enables the equipment to operate reliably for a long time.
Smart Images

Figure CN120652886A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data acquisition, and in particular to a pulse signal acquisition method and device. Background Art
[0002] In smart water systems leveraging Industrial Internet of Things (IIoT) data collection, field-deployed flow meters, such as ultrasonic, electromagnetic, and pulse flow meters, are often installed in extremely harsh environments without external power supplies. These devices often utilize open-drain pulse output interfaces and rely on battery power, placing extremely high demands on power consumption.
[0003] Common data collection solutions currently include: 1. External interrupt collection: While collecting data through external interrupts can effectively reduce power consumption, it has poor anti-interference capabilities, resulting in inaccurate collection accuracy. 2. Delayed de-jitter collection: Delayed de-jitter improves collection stability, but significantly increases power consumption. Summary of the Invention The technical problem to be solved by the present invention is to provide a pulse signal acquisition method and device, which can improve the stability of data acquisition and enable the equipment to operate reliably for a long time.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is: A pulse signal acquisition method, comprising: Determine whether a start interrupt signal is received, and if so, wake up the acquisition device; Starting a collection cycle timer and putting the collection device into a dormant state; Determine whether the first sampling cycle time preset by the acquisition cycle timer has been reached, and if so, wake up the acquisition device to collect data, and put the acquisition device into a dormant state after the collection; Determine whether a stop interrupt signal is received, and if so, turn off the acquisition cycle timer and put the acquisition device into sleep mode.
[0005] In order to solve the above technical problems, another technical solution adopted by the present invention is: A pulse signal acquisition device includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the following steps when executing the computer program: Determine whether a start interrupt signal is received, and if so, wake up the acquisition device; Starting a collection cycle timer and putting the collection device into a dormant state; Determine whether the first sampling cycle time preset by the acquisition cycle timer has been reached, and if so, wake up the acquisition device to collect data, and put the acquisition device into a dormant state after the collection; Determine whether a stop interrupt signal is received, and if so, turn off the acquisition cycle timer and put the acquisition device into sleep mode.
[0006] The beneficial effects of the present invention are: by further setting an acquisition cycle timer on the basis of interrupt wake-up, the acquisition cycle timer controls the acquisition device to perform acquisition in a periodic interrupt manner, and combines interrupt wake-up with periodic interrupt acquisition. Compared with the existing acquisition device that is awakened by interruption and then continues to acquire after entering the acquisition state, the present invention sets an acquisition cycle timer to control the acquisition of the acquisition device through the interrupt signal generated by the acquisition cycle timer after entering the acquisition state, further reducing the power consumption of the acquisition device, and based on the double interrupt, improving the anti-interference ability of the acquisition device and improving the acquisition stability, thereby ensuring the accuracy of data acquisition and enabling the acquisition device to operate reliably for a long time. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] Figure 1 This is a flow chart of the steps of a pulse signal acquisition method according to an embodiment of the present invention; Figure 2 A pulse signal schematic diagram of a pulse signal acquisition method according to an embodiment of the present invention; Figure 3 The figure is a schematic structural diagram of a pulse signal acquisition device in an embodiment of the present invention. DETAILED DESCRIPTION
[0008] To illustrate the technical content, achieved objectives and effects of the present invention in detail, the following description is given in conjunction with the embodiments and accompanying drawings.
[0009] Please refer to Figure 1 , a pulse signal acquisition method, comprising: Determine whether a start interrupt signal is received, and if so, wake up the acquisition device; Starting a collection cycle timer and putting the collection device into a dormant state; Determine whether the first sampling cycle time preset by the acquisition cycle timer has been reached, and if so, wake up the acquisition device to collect data, and put the acquisition device into a dormant state after the collection; Determine whether a stop interrupt signal is received, and if so, turn off the acquisition cycle timer and put the acquisition device into sleep mode.
[0010] From the above description, it can be seen that the beneficial effect of the present invention is: by further setting an acquisition cycle timer on the basis of interrupt wake-up, the acquisition cycle timer controls the acquisition device to perform acquisition in a periodic interrupt manner, and combines interrupt wake-up with periodic interrupt acquisition. Compared with the existing acquisition device that is awakened by interruption and then continues to acquire after entering the acquisition state, the present invention sets an acquisition cycle timer to control the acquisition of the acquisition device through the interrupt signal generated by the acquisition cycle timer after entering the acquisition state, further reducing the power consumption of the acquisition device, and based on the double interrupt, improving the anti-interference ability of the acquisition device, improving the acquisition stability, thereby ensuring the accuracy of data acquisition and enabling the acquisition device to operate reliably for a long time.
[0011] Furthermore, after waking up the acquisition device to acquire data, the method further includes: Record the current cumulative sampling times; Determine whether the cumulative number of sampling times exceeds a preset number range; if so, extend the first sampling cycle time.
[0012] From the above description, it can be seen that by recording the cumulative sampling times after the acquisition device acquires data and extending the first sampling cycle time when the cumulative sampling times exceed the preset range, the sampling times of the acquisition device are reduced and the power consumption of the acquisition device is reduced.
[0013] Furthermore, after determining whether a stop interrupt signal is received, the method further includes: Obtaining an acquisition state time according to the start interrupt signal and the stop interrupt signal; Calculate the number of periodic sampling times according to the acquisition state time and the first sampling cycle time; It is determined whether the number of periodic sampling times is within a preset number range. If not, the first sampling cycle time is adjusted to obtain a second sampling cycle time, and the second sampling cycle time is used as the sampling cycle of the acquisition cycle timer.
[0014] From the above description, it can be seen that the pulse signal acquisition cycle of different types of equipment is usually different. By obtaining the acquisition state time based on the start interrupt signal and the stop interrupt signal after completing an acquisition state, the pulse signal acquisition cycle of the current device can be obtained; and after calculating the number of periodic sampling times based on the acquisition state time and the first sampling cycle time, the first sampling cycle time is adjusted to obtain the second sampling cycle time, so that the sampling period of the acquisition cycle timer can be dynamically adjusted to achieve compatibility with different types of equipment, so that the device can be used in any type of equipment and can operate in a low-power form.
[0015] Furthermore, adjusting the first sampling cycle time to obtain a second sampling cycle time includes: The second sampling cycle time is less than half of the acquisition state time.
[0016] From the above description, it can be seen that by setting the second sampling cycle time to be less than half of the acquisition state time, that is, the acquisition state time is at least twice the second sampling cycle time, the acquisition device satisfies the Nyquist sampling theorem, thereby being able to restore the signal without distortion and ensure the stability of the signal.
[0017] Furthermore, adjusting the first sampling cycle time to obtain the second sampling cycle time further includes: The acquisition state time is less than ten times the second sampling cycle time.
[0018] From the above description, it can be seen that on the basis of ensuring that the acquisition state time is at least twice the second sampling cycle time, the acquisition state time is set to be less than ten times the second sampling cycle time to avoid the second sampling cycle time being too short, resulting in the acquisition device frequently collecting data during the acquisition state time, resulting in increased power consumption.
[0019] Another embodiment of the present invention provides a pulse signal acquisition device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the following steps when executing the computer program: Determine whether a start interrupt signal is received, and if so, wake up the acquisition device; Starting a collection cycle timer and putting the collection device into a dormant state; Determine whether the first sampling cycle time preset by the acquisition cycle timer has been reached, and if so, wake up the acquisition device to collect data, and put the acquisition device into a dormant state after the collection; Determine whether a stop interrupt signal is received, and if so, turn off the acquisition cycle timer and put the acquisition device into sleep mode.
[0020] From the above description, it can be seen that the beneficial effect of the present invention is: by further setting an acquisition cycle timer on the basis of interrupt wake-up, the acquisition cycle timer controls the acquisition device to perform acquisition in a periodic interrupt manner, and combines interrupt wake-up with periodic interrupt acquisition. Compared with the existing acquisition device that is awakened by interruption and then continues to acquire after entering the acquisition state, the present invention sets an acquisition cycle timer to control the acquisition of the acquisition device through the interrupt signal generated by the acquisition cycle timer after entering the acquisition state, further reducing the power consumption of the acquisition device, and based on the double interrupt, improving the anti-interference ability of the acquisition device, improving the acquisition stability, thereby ensuring the accuracy of data acquisition and enabling the acquisition device to operate reliably for a long time.
[0021] Furthermore, after waking up the acquisition device to acquire data, the method further includes: Record the current cumulative sampling times; Determine whether the cumulative number of sampling times exceeds a preset number range; if so, extend the first sampling cycle time.
[0022] From the above description, it can be seen that by recording the cumulative sampling times after the acquisition device acquires data and extending the first sampling cycle time when the cumulative sampling times exceed the preset range, the sampling times of the acquisition device are reduced and the power consumption of the acquisition device is reduced.
[0023] Furthermore, after determining whether a stop interrupt signal is received, the method further includes: Obtaining an acquisition state time according to the start interrupt signal and the stop interrupt signal; Calculate the number of periodic sampling times according to the acquisition state time and the first sampling cycle time; It is determined whether the number of periodic sampling times is within a preset number range. If not, the first sampling cycle time is adjusted to obtain a second sampling cycle time, and the second sampling cycle time is used as the sampling cycle of the acquisition cycle timer.
[0024] From the above description, it can be seen that the pulse signal acquisition cycle of different types of equipment is usually different. By obtaining the acquisition state time based on the start interrupt signal and the stop interrupt signal after completing an acquisition state, the pulse signal acquisition cycle of the current device can be obtained; and after calculating the number of periodic sampling times based on the acquisition state time and the first sampling cycle time, the first sampling cycle time is adjusted to obtain the second sampling cycle time, so that the sampling period of the acquisition cycle timer can be dynamically adjusted to achieve compatibility with different types of equipment, so that the device can be used in any type of equipment and can operate in a low-power form.
[0025] Furthermore, adjusting the first sampling cycle time to obtain a second sampling cycle time includes: The second sampling cycle time is less than half of the acquisition state time.
[0026] From the above description, it can be seen that by setting the second sampling cycle time to be less than half of the acquisition state time, that is, the acquisition state time is at least twice the second sampling cycle time, the acquisition device satisfies the Nyquist sampling theorem, thereby being able to restore the signal without distortion and ensure the stability of the signal.
[0027] Furthermore, adjusting the first sampling cycle time to obtain the second sampling cycle time further includes: The acquisition state time is less than ten times the second sampling cycle time.
[0028] From the above description, it can be seen that on the basis of ensuring that the acquisition state time is at least twice the second sampling cycle time, the acquisition state time is set to be less than ten times the second sampling cycle time to avoid the second sampling cycle time being too short, resulting in the acquisition device frequently collecting data during the acquisition state time, resulting in increased power consumption.
[0029] The pulse signal acquisition method and device provided by the present invention can be applied to scenarios where pulse signals are collected, for example, for field data collection of various flow meters in smart water systems. The following describes the method and device through specific implementation methods: Example 1 Please refer to Figure 1 , a pulse signal acquisition method, comprising: S1, determine whether the start interrupt signal is received, if so, wake up the acquisition device; Figure 2 As shown, a pulse signal consists of an idle state, a startup state, a collection state, and an end state. The collection state duration varies for devices of different manufacturers, models, and brands. For example, some devices have a collection state period greater than 10ms, while others have a period of 200ms. Initially, the collection device remains dormant to reduce power consumption. It wakes up only when it receives a startup interrupt signal.
[0030] S2. Start the collection cycle timer and put the collection device into a dormant state. That is, after the collection device is awakened, the collection cycle timer is started and the device enters the dormant state again. In an optional embodiment, based on actual data collection requirements, the collection device may be allowed to collect data once before entering the dormant state.
[0031] S3. Determine whether the first sampling cycle time preset by the acquisition cycle timer has been reached. If so, wake up the acquisition device to collect data, and put the acquisition device into a dormant state after the collection. For example, the sampling period (fsigna) of the acquisition cycle timer is set to 2ms by default, that is, the first sampling cycle time is 2ms. When it reaches 2ms, the acquisition device is woken up to collect valid pulses and enters dormancy again. That is, after entering the startup state, a 100us acquisition is performed after 2ms, and then a second acquisition is performed after another 2ms, until the stop interrupt signal is received and the device enters the end state. Since the acquisition time is only 100us, waking up the device through the acquisition cycle timer can not only reduce power consumption by 90%, but also provide acquisition stability and improve anti-interference ability.
[0032] Among them, in an optional embodiment, the current cumulative number of samplings is recorded after data collection; and it is determined whether the cumulative number of samplings exceeds the preset number range. If so, the first sampling cycle time is extended; for example, the preset number is 10 times, if 10 collections have been performed, the subsequent sampling cycles are delayed, or the collection is stopped.
[0033] S4. Determine whether a stop interrupt signal is received. If so, turn off the acquisition cycle timer and put the acquisition device to sleep; that is, when the acquisition device enters the end state, it will stop acquiring. At this time, the acquisition state time (fsampl) can be obtained according to the start interrupt signal and the stop interrupt signal, that is, the time from the start state to the end state is obtained, and the periodic sampling number is calculated according to the acquisition state time and the first sampling cycle time. For example, the acquisition state time is 20ms and the sampling cycle time is 2ms, that is, the periodic sampling number is 10 times; or the periodic sampling number is obtained according to the recorded cumulative sampling number and the default sampling cycle.
[0034] At the same time, it is determined whether the number of periodic sampling times is within a preset number range. If not, the first sampling cycle time is adjusted to obtain a second sampling cycle time, and the second sampling cycle time is used as the sampling cycle of the acquisition cycle timer; for example, the second sampling cycle time is less than half of the acquisition state time, and the second sampling cycle time is greater than one tenth of the acquisition state time.
[0035] like Figure 2 As shown, the pulse signal acquisition period (acquisition state time fsampl) of devices of different manufacturers, different models, and different brands is different. Some manufacturers' acquisition state period is 200ms. If a fixed 2ms acquisition period is used for data acquisition, it will waste resources. In an optional embodiment, considering power consumption compatibility, stability, and distortion-free signal restoration, the preferred adjustment range is set to make the sampling period time close to: fsampl ≥ 5fsignal; For example, if the acquisition state time is 20ms and the number of recorded periodic sampling times is 10, the unadjusted acquisition period is the default period of 2ms. That is, at this time, the number of periodic sampling times does not meet the condition close to fsampl ≥ 5fsignal. Therefore, the sampling period of the acquisition period timer needs to be adjusted by extending the sampling period time to meet the condition close to fsampl ≥ 5fsignal. For example, the second sampling period time is adjusted to 4ms. By dynamically adjusting the sampling period time of the acquisition period timer, the compatibility with devices of different manufacturers, models, and brands is improved, while the power consumption is reduced by 90% under the premise of ensuring the stability of the device through dynamic adaptation.
[0036] Example 2 Please refer to Figure 3 A pulse signal acquisition device includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the following steps when executing the computer program: S1. Determine whether a start interrupt signal is received. If so, wake up the acquisition device. S2, start the collection cycle timer and put the collection device into a dormant state; S3. Determine whether the first sampling cycle time preset by the acquisition cycle timer has been reached. If so, wake up the acquisition device to collect data and put the acquisition device into a dormant state after the collection. In an optional embodiment, record the current cumulative number of samplings after data collection; and determine whether the cumulative number of samplings exceeds a preset number range. If so, extend the first sampling cycle time.
[0037] S4. Determine whether a stop interrupt signal is received. If so, disable the acquisition cycle timer and put the acquisition device into hibernation. Simultaneously, obtain the acquisition state time based on the start interrupt signal and the stop interrupt signal, and calculate the number of periodic samplings based on the acquisition state time and the first sampling cycle time. Further determine whether the number of periodic samplings is within a preset range. If not, adjust the first sampling cycle time to obtain a second sampling cycle time, and use the second sampling cycle time as the sampling period of the acquisition cycle timer. For example, set the second sampling cycle time to be less than half of the acquisition state time and greater than one-tenth of the acquisition state time.
[0038] In summary, the present invention provides a pulse signal acquisition method that further sets an acquisition cycle timer based on interrupt wakeup, and the acquisition cycle timer controls the acquisition device to perform acquisition in a periodic interrupt manner, combining interrupt wakeup with periodic interrupt acquisition. Compared with the existing method of waking up the acquisition device through interruption and then continuing to acquire data after the acquisition device enters the acquisition state, the present invention sets an acquisition cycle timer to control the acquisition of the acquisition device through the interrupt signal generated by the acquisition cycle timer after entering the acquisition state, further reducing the power consumption of the acquisition device. In addition, based on the dual interrupt, the anti-interference ability of the acquisition device is improved, and the acquisition stability is improved, thereby ensuring the accuracy of data acquisition and enabling the acquisition device to operate reliably for a long time. In addition, by dynamically adjusting the sampling cycle time of the acquisition cycle timer, the compatibility with devices of different manufacturers, different models, and different brands is improved, while the power consumption is reduced by 90% under the premise of ensuring the stability of the device through dynamic adaptive means.
[0039] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's description and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A pulse signal acquisition method, characterized in that: include: Determine whether a start interrupt signal is received, and if so, wake up the acquisition device; Starting a collection cycle timer and putting the collection device into a dormant state; Determine whether the first sampling cycle time preset by the acquisition cycle timer has been reached, and if so, wake up the acquisition device to collect data, and put the acquisition device into a dormant state after the collection; Determine whether a stop interrupt signal is received, and if so, turn off the acquisition cycle timer and put the acquisition device into sleep mode.
2. A pulse signal acquisition method according to claim 1, characterized in that: After waking up the acquisition device to acquire data, the method further comprises: Record the current cumulative sampling times; Determine whether the cumulative number of sampling times exceeds a preset number range; if so, extend the first sampling cycle time.
3. A pulse signal acquisition method according to claim 1, characterized in that: After determining whether a stop interrupt signal is received, the method further includes: Obtaining an acquisition state time according to the start interrupt signal and the stop interrupt signal; Calculate the number of periodic sampling times according to the acquisition state time and the first sampling cycle time; It is determined whether the number of periodic sampling times is within a preset number range. If not, the first sampling cycle time is adjusted to obtain a second sampling cycle time, and the second sampling cycle time is used as the sampling cycle of the acquisition cycle timer.
4. A pulse signal acquisition method according to claim 3, characterized in that: The adjusting the first sampling cycle time to obtain the second sampling cycle time includes: The second sampling cycle time is less than half of the acquisition state time.
5. A pulse signal acquisition method according to claim 4, characterized in that: The adjusting the first sampling cycle time to obtain the second sampling cycle time further includes: The second sampling cycle time is greater than one tenth of the acquisition state time.
6. A pulse signal acquisition device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: Determine whether a start interrupt signal is received, and if so, wake up the acquisition device; Starting a collection cycle timer and putting the collection device into a dormant state; Determine whether the first sampling cycle time preset by the acquisition cycle timer has been reached, and if so, wake up the acquisition device to collect data, and put the acquisition device into a dormant state after the collection; Determine whether a stop interrupt signal is received, and if so, turn off the acquisition cycle timer and put the acquisition device into sleep mode.
7. A pulse signal acquisition device according to claim 6, characterized in that: After waking up the acquisition device to acquire data, the method further comprises: Record the current cumulative sampling times; Determine whether the cumulative number of sampling times exceeds a preset number range; if so, extend the first sampling cycle time.
8. The pulse signal acquisition device according to claim 6, characterized in that: After determining whether a stop interrupt signal is received, the method further includes: Obtaining an acquisition state time according to the start interrupt signal and the stop interrupt signal; Calculate the number of periodic sampling times according to the acquisition state time and the first sampling cycle time; It is determined whether the number of periodic sampling times is within a preset number range. If not, the first sampling cycle time is adjusted to obtain a second sampling cycle time, and the second sampling cycle time is used as the sampling cycle of the acquisition cycle timer.
9. The pulse signal acquisition device according to claim 8, characterized in that: The adjusting the first sampling cycle time to obtain the second sampling cycle time includes: The second sampling cycle time is less than half of the acquisition state time.
10. The pulse signal acquisition device according to claim 9, characterized in that: The adjusting the first sampling cycle time to obtain the second sampling cycle time further includes: The second sampling cycle time is greater than one tenth of the acquisition state time.