Special transformer terminal platform based on high-precision timer and pulse metering method thereof
By integrating high-precision timer and debounce filtering algorithm in the special-change terminal platform, the hardware cost and software complexity are reduced, while improving the accuracy of pulse metering, solving the problems of high costs and complexity in the existing technology.
Patent Information
- Application Number
- CN202510424191.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-07
- Publication Date
- 2025-07-25
AI Technical Summary
The existing dedicated terminal platform has high hardware cost and high software complexity, mainly due to the increased communication demand caused by the dual-main control unit architecture.
The high-precision timer is used to integrate real-time IO control function in the CPU, and pulse measurement is performed through sliding window statistics and debounce filtering algorithm, which is simplified into a single master control unit architecture.
It reduces hardware cost and software complexity, improves the accuracy of pulse metering, and simplifies the communication requirements between dual master control units.
Smart Images

Figure CN120371083A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electric power metering, and particularly relates to a dedicated transformer terminal platform based on a high-precision timer and its pulse metering method. Background Technique
[0002] According to the requirements of the dedicated transformer terminal technical specification, the terminal needs to implement the function of pulse quantity acquisition, and is required to have the ability to collect meter pulses with an error not greater than 1 pulse. The specific description is as follows: The complete electrical energy pulse output should be greater than 60 ms, and the high / low level output should not be less than 30 ms. When there is a pulse output at the electrical pulse output port, the voltage drop at the pulse output port when passing through a 5 mA current shall not be higher than 0.8 V. When there is no pulse output, the DC impedance of the pulse output port shall not be less than 100 kΩ. In the existing dedicated transformer terminal platform, the acquisition of high-frequency pulses usually relies on a dual-master unit architecture, where one master unit is a CPU running the Linux system, and the other master unit is an MCU running a real-time operating system. The former is responsible for processing complex business logics, and the latter is responsible for efficient IO control. Although this architecture is powerful, the dual-master units it depends on result in a high hardware cost and the need to handle the communication between the two master units, which increases the complexity of the software. Summary of the Invention
[0003] In order to reduce the hardware cost of the dedicated transformer terminal platform and at the same time reduce the communication complexity caused by the dual-master units, the present invention provides a dedicated transformer terminal platform based on a high-precision timer and its pulse metering method. By integrating the real-time IO control function into the CPU running the Linux system, the hardware cost is reduced, and at the same time, the need for communication between the dual-master units is eliminated, simplifying the software architecture and reducing the overall complexity.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is as follows: A pulse metering method for a dedicated transformer terminal platform based on a high-precision timer, comprising the following steps:
[0005] Step 1: Configure the sampling pin as the input state; at the same time, configure the expiration time of the high-precision timer and start it;
[0006] Step 2: Determine whether the timer has expired. If so, sample each path of pulse signal and store them in memory variables respectively;
[0007] Step 3: Use a sliding window to count the number of 1s and 0s in the memory variables. If the number of 1s in the window exceeds the threshold, determine that the window is the pulse high level. If the number of 0s in the window exceeds the threshold, determine that the window is the pulse low level. Otherwise, it is regarded as jitter;
[0008] Step 4: Perform pulse metering according to the statistical results of the sliding window.
[0009] In step 1, the expiration time of the high-precision timer is configured to be 1 to 10 milliseconds.
[0010] In step 1, the expiration time of the high-precision timer is configured to be 5 milliseconds.
[0011] In step 3, the size of the sliding window is 16, and the threshold value is 10.
[0012] In step 4, the specific method for pulse measurement is as follows:
[0013] (1) Determine whether there is a change in the pulse level within two adjacent windows. If there is, accumulate the number of pulse position changes and record the position change time;
[0014] (2) Calculate the number of pulses according to the number of pulse position changes.
[0015] In step 4, the calculation formula for the number of pulses is: the number of pulses = the number of pulse position changes / 2.
[0016] In addition, the present invention also provides a dedicated transformer terminal platform based on a high-precision timer, which uses the described pulse measurement method for pulse measurement.
[0017] The dedicated transformer terminal platform based on a high-precision timer includes a CPU running a Linux system, and the high-precision timer is set in the Linux system.
[0018] The processing flow of the expiration function of the high-precision timer is set to respectively identify, sample, and store each path of pulse signal.
[0019] The present invention has the following beneficial effects compared with the prior art:
[0020] The present invention provides a dedicated transformer terminal platform based on a high-precision timer and its pulse measurement method. By setting a high-precision timer in the CPU, sampling data using a reasonable timer expiration time, and processing the sampled data in combination with a debounce filtering algorithm, high-frequency pulses and low-frequency pulses can be effectively eliminated, improving the accuracy of pulse measurement. Moreover, the present invention does not require a dual master control unit for pulse measurement, simplifies the communication requirements between the dual master control units, simplifies the software architecture, and reduces the overall complexity. Brief Description of the Drawings
[0021] Figure 1 It is a schematic flow chart of a pulse measurement method for a dedicated transformer terminal platform based on a high-precision timer proposed in Embodiment 1 of the present invention;
[0022] Figure 2 It is a schematic diagram of data sampling in an embodiment of the present invention. Detailed Description of the Embodiment
[0023] To make the technical solutions and advantages of the present invention clearer, the following will, in conjunction with specific embodiments and drawings, clearly and completely describe the technical solutions of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention; all other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without making creative efforts fall within the scope of protection of the present invention.
[0024] Embodiment 1
[0025] As Figure 1 shown, Embodiment 1 of the present invention provides a pulse metering method for a dedicated transformer terminal platform based on a high-precision timer, including the following steps:
[0026] Step 1: Configure the sampling pin as an input state; at the same time, configure the expiration time of the high-precision timer and start it.
[0027] Specifically, in this embodiment, in Step 1, the expiration time of the high-precision timer is configured to be 1 to 10 milliseconds.
[0028] Further, in this embodiment, in Step 1, the expiration time of the high-precision timer is configured to be 5 milliseconds.
[0029] Step 2: Determine whether the timer has expired. If so, sample each path of pulse signal and store them separately in memory variables.
[0030] Specifically, in this embodiment, the sampled pulse signals of each path are stored in local 32-bit memory variables.
[0031] Step 3: Process the sampled pulse signals through a debounce filtering algorithm.
[0032] Specifically, the specific method of the debounce filtering algorithm is: use a sliding window to count the number of 1s and 0s in the memory variable. If the number of 1s in the window exceeds the threshold, it is determined that the window is a pulse high level. If the number of 0s in the window exceeds the threshold, it is determined that the window is a pulse low level. Otherwise, it is regarded as jitter.
[0033] Specifically, in this embodiment, in Step 3, the size of the sliding window is 16, and the threshold value is 10. Specifically, the step size of the sliding window can be set to 1.
[0034] In this embodiment, the expiration time of the high-precision timer is set to 5 milliseconds, and the timer will restart immediately after expiration. Regarding the debounce filtering algorithm, it uses a sliding window method to count the sampled data. Specifically, if the number of sampled values of 1 exceeds 10 among the most recent 16 sampled values, it is determined as a high pulse level; conversely, if the number of sampled values of 0 exceeds 10, it is determined as a low pulse level, and the remaining values are regarded as pulse jitters. As Figure 2 shown, it is a schematic diagram of a sampled data, where the horizontal axis is time, and the vertical arrow dashed line is the sampling point when the timer expires, and the sampled values are: 0001111001111. The debounce filtering algorithm of this embodiment can effectively eliminate two types of jitters. One is the high-frequency pulse below 5 milliseconds. If the high frequency (interference) occurs between two samplings (less than 5 milliseconds), such as Figure 2 the high level between the first interval (the first sampling point and the second sampling point) in, then when the timer expires for sampling, the change of this pulse level cannot be sampled, and naturally it is not regarded as a change in position, and it will not be counted into the number of pulses; the second is that it can eliminate the low-frequency pulses between 5 milliseconds and 30 milliseconds, such as Figure 2 the sampled value 0 sampled data shown in. Although this low-frequency pulse (interference) is sampled, if the cumulative number of sampled points does not reach the threshold, it cannot be regarded as a valid change in position. Therefore, it will not affect the accuracy of pulse measurement. Therefore, this embodiment can effectively eliminate the influence of high-frequency pulses and low-frequency pulses on pulse measurement through the debounce filtering algorithm.
[0035] Step 4: Perform pulse measurement according to the statistical results of the sliding window.
[0036] Specifically, in this embodiment, in the said step 4, the specific method for performing pulse measurement is:
[0037] (1) Judge whether there is a change in the pulse level between two adjacent windows. If there is, accumulate the number of pulse position changes;
[0038] (2) Calculate the number of pulses according to the number of pulse position changes.
[0039] Specifically, a complete pulse is composed of a high pulse and a low pulse. Therefore, in this embodiment, it is considered that the number of two pulse position changes is equal to the number of one pulse. Therefore, in the said step 4, the calculation formula for the number of pulses is:
[0040] Number of pulses = Number of pulse position changes / 2; (1)
[0041] After actual test verification, the pulse metering method of the present invention can reliably meter the number of pulses and the pulse occurrence time at pulse frequencies from 12 to 120 per minute. Moreover, it only needs to set a high-precision timer in the CPU to achieve counting. Compared with the design scheme of the main control CPU cooperating with the pulse sampling MCU in the prior art, the present invention not only reduces the hardware cost, but also eliminates the communication mechanism between the two, thereby reducing the software complexity.
[0042] Embodiment 2
[0043] Embodiment 2 of the present invention provides a dedicated transformer terminal platform based on a high-precision timer, which uses the pulse metering method described in Embodiment 1 for pulse metering.
[0044] Specifically, a dedicated transformer terminal platform based on a high-precision timer in this embodiment includes a CPU running a Linux system. The high-precision timer is set in the Linux system, that is, pulse counting can be achieved, and the metering is accurate.
[0045] Further, the expiration function processing flow of the high-precision timing is set to separately identify, sample, and store each path of pulse signal.
[0046] In this embodiment, the timeliness of the pulse acquisition process of the pulse metering method is guaranteed by the high-precision timer of the Linux system, and then the pulse metering is realized by relying on the multiple-sampling and superposition anti-jitter filtering algorithm built in the CPU. Among them, the high-precision timing subsystem of the Linux system is based on the timer interrupt provided by the hardware and can provide clock accuracy at the nanosecond level, meeting the technical requirements in terms of real-time performance. At the same time, the sampling algorithm in the CPU performs high-speed interval sampling on the pulse signal according to this timer, and performs smoothing processing on the sampled data by superimposing the anti-jitter filtering algorithm, and finally high-fidelity pulse metering data can be obtained.
[0047] The above has described the embodiments of the present invention in detail with reference to the drawings. However, the present invention is not limited to the above embodiments, and various changes can be made without departing from the gist of the present invention within the knowledge scope of those of ordinary skill in the art.
Claims
1. A pulse metering method for a special transformer terminal platform based on a high-precision timer, characterized in that, Including the following steps: Step 1: Configure the sampling pin to the input state; at the same time, configure the expiration time of the high-precision timer and start it; Step 2: Determine whether the timer has expired. If so, sample each pulse signal and store them separately in memory variables; Step 3: Use a sliding window to count the number of 1s and 0s in the memory variables. If the number of 1s in the window exceeds the threshold, determine that the window is the pulse high level. If the number of 0s in the window exceeds the threshold, determine that the window is the pulse low level. Otherwise, it is regarded as jitter; Step 4: Perform pulse metering according to the statistical results of the sliding window.
2. The pulse metering method for a dedicated transformer terminal platform based on a high-precision timer according to claim 1, wherein In the said Step 1, the expiration time of the high-precision timer is configured to be 1 to 10 milliseconds.
3. A pulse metering method for a dedicated transformer terminal platform based on a high-precision timer according to claim 1, characterized in that, In the said Step 1, the expiration time of the high-precision timer is configured to be 5 milliseconds.
4. A pulse metering method for a dedicated transformer terminal platform based on a high-precision timer according to claim 1, characterized in that In the said Step 3, the size of the sliding window is 16, and the threshold value is 10.
5. A pulse metering method for a dedicated transformer terminal platform based on a high-precision timer according to claim 1, characterized in that, In the said Step 4, the specific method for performing pulse metering is: (1) Determine whether the pulse levels in two adjacent windows have changed. If so, accumulate the number of pulse level changes and record the change time; (2) Calculate the number of pulses according to the number of pulse level changes.
6. A pulse metering method for a dedicated transformer terminal platform based on a high-precision timer according to claim 5, characterized in that, In the said Step 4, the calculation formula for the number of pulses is: Number of pulses = Number of pulse level changes / 2.
7. A dedicated transformer terminal platform based on a high-precision timer, characterized in that, Perform pulse metering using the pulse metering method described in any one of claims 1 to 5.
8. The dedicated transformer terminal platform based on a high-precision timer according to claim 7, wherein, It includes a CPU running the Linux system, and the high-precision timer is set in the Linux system.
9. The special transformer terminal platform based on a high-precision timer according to claim 8, wherein, The processing flow of the expiration function of the high-precision timer is set to identify, sample and store each pulse signal separately.