A method and module for counting pulse inputs of a metering terminal and a metering terminal

By utilizing the level state of the pulse signal to trigger interrupts and delay mechanisms, the problem of unbalanced MCU load and accuracy in traditional pulse detection is solved, achieving efficient and accurate pulse counting and power calculation.

CN117590062BActive Publication Date: 2026-06-19ANHUI ZENITH ELECTRICITY & ELECTRONICS

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ANHUI ZENITH ELECTRICITY & ELECTRONICS
Filing Date
2023-11-23
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Traditional pulse detection methods struggle to balance MCU load and detection accuracy. High-frequency sampling leads to excessive MCU load, while low-frequency sampling results in inaccurate pulse signal counting.

Method used

The pulse signal level is used as the interrupt trigger condition. The interrupt mechanism is used to count pulses, a preset delay period is set to remove signal jitter, and the complete pulse is determined by detecting the pulse start and end flags, and the pulse frequency and power are calculated.

Benefits of technology

While reducing the MCU's burden and power consumption, it improves the accuracy and efficiency of pulse counting and simplifies the signal processing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117590062B_ABST
    Figure CN117590062B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of power equipment, specifically relating to a pulse input counting method for a dedicated transformer terminal, a pulse input counting module, and a corresponding dedicated transformer terminal. The counting method includes the following steps: S1: Detect the connection status of the pulse output device. S2: Set the interrupt trigger condition of the MCU to the rising and falling edges of the received pulse signal. S3: Set a preset delay for the interrupt start time. S4: Register the interrupt handling process and detect the type of triggered pulse. S5: If triggered by a falling edge, set the pulse start flag to a high level; if triggered by a rising edge, set the pulse end flag to a high level. S6: When both the pulse start and end flags are high, count the pulses. S7: Obtain the pulse count value and pulse interval according to a preset sampling period, calculate the pulse power, and complete the power data statistics. This invention solves the problem that traditional pulse detection methods struggle to balance MCU load and detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of power equipment, specifically relating to a pulse input counting method for a dedicated transformer terminal, a pulse input counting module, and the corresponding dedicated transformer terminal. Background Technology

[0002] According to the DLT614-2017 multi-function meter protocol and terminal specifications, the meter should have LED pulse and power pulse output functions proportional to energy consumption, typically with a pulse width of 80±20ms. The terminal receives the pulses output by the meter, counts the pulse signals, and then calculates the average power by combining the meter's pulse constant, changes in the voltage transformer (TV) and current transformer (TA), and records the maximum power value and occurrence time for the day and month.

[0003] Traditional power equipment uses periodic sampling levels to acquire pulse signals. This method detects pulse signals by continuously scanning them, then determines the pulse duration and width based on level changes, and counts the pulses. The pulse power can also be calculated using the pulse width, pulse interval, and the number of pulses per unit time. Traditional pulse signal acquisition is implemented by periodically sampling levels using a timer interrupt from an MCU chip, recording the corresponding data based on the high and low levels.

[0004] In traditional pulse signal detection methods, improving detection accuracy requires continuously increasing the transmission frequency of the sampling level to ensure it exceeds the pulse signal frequency. However, high-frequency sampling leads to frequent interrupts, excessively burdening the MCU. Conversely, if the sampling level frequency is lower than the pulse signal frequency, some pulse counts will be lost, affecting the accuracy of the detection results. Therefore, finding more efficient ways to utilize the processor and accurately read pulse data is a worthwhile research direction. Summary of the Invention

[0005] To address the challenge of balancing MCU load and detection accuracy in traditional pulse detection methods, this invention provides a pulse input counting method for a dedicated transformer terminal, a pulse input counting module, and a corresponding dedicated transformer terminal.

[0006] This invention is achieved using the following technical solution:

[0007] A pulse input counting method for a dedicated transformer terminal uses the level state of the input pulse signal as the interrupt trigger condition and utilizes an interrupt mechanism to count the pulse inputs. The pulse input counting method provided by this invention includes the following steps:

[0008] S1: Detect the connection status of the pulse output device so that the dedicated transformer terminal can receive the pulse signal input by the pulse output device.

[0009] S2: Set the MCU's interrupt trigger condition to the rising and falling edges of the received pulse signal.

[0010] S3: Set a preset delay for the start of the interrupt to establish a mechanism for removing signal jitter.

[0011] If no interrupt is triggered again within the preset delay period after the interrupt triggering conditions are met, the interrupt process begins.

[0012] S4: Register the interrupt handler process and detect the type of the pulse that triggers the interrupt.

[0013] S5: Based on the type of pulse detected, make the following judgment:

[0014] (1) If it is a falling edge, set the pulse start flag to high level and record the time of the falling edge arrival.

[0015] (2) If it is a rising edge, set the pulse end flag to high level, record the rising edge arrival time, and wait for the interrupt to be triggered again.

[0016] S6: Determine whether the pulse start flag and pulse end flag are both high. If so, a complete pulse is detected and the pulses are counted.

[0017] S7: Obtain the pulse count value and pulse interval according to the preset sampling period, calculate the pulse power, and complete the power data statistics.

[0018] As a further improvement of the present invention, in step S1, the pulse output device includes an energy meter and other measuring devices that use pulses for measurement; the pulse output device and the special transformer terminal are connected via an RS-485 interface for communication.

[0019] As a further improvement of the present invention, in the interrupt triggering conditions of the MCU set in step S2, a triggering condition for the interrupt to start when a rising edge is detected and a triggering condition for the interrupt to end when a falling edge is detected are defined.

[0020] As a further improvement of the present invention, in step S3, when the interrupt is triggered again within the preset delay period after the interrupt triggering condition is met, the time of the second triggering is taken as the interrupt triggering time, and the system continues to wait for the next round of delay and judgment.

[0021] As a further improvement of the present invention, in step S5, the pulse start flag is defined as flagL and the pulse end flag is defined as flagH. In the initial state, flagL = 0 and flagH = 0. When an interrupt is triggered and a falling edge is detected, the pulse start flag is set to 1, i.e., flagL = 1. When an interrupt is triggered and a rising edge is detected, the pulse end flag is set to 1, i.e., flagH = 1.

[0022] As a further improvement of the present invention, in step S6, the method for detecting a complete pulse is as follows: after each time the pulse end flag is set to a high level, it is determined whether the pulse start flag has been set to a high level.

[0023] (1) If so, then determine that a complete pulse has been detected, count the pulses, and reset the pulse start flag and pulse end flag to low level.

[0024] (2) If not, it is determined that the detected pulse is not a complete pulse, the detection result is discarded, and the pulse end flag is reset to low level.

[0025] As a further improvement of the present invention, in step S7, the pulse frequency is calculated using the pulse counting results, and the average power P is calculated based on the pulse constant of the energy meter. Then, the maximum value and occurrence time of the power for the day and month are recorded. The formula for calculating the average power P is as follows:

[0026] P = 3600f / Kp

[0027] In the above formula, f represents the pulse frequency in Hz, and Kp is the pulse frequency, which represents the number of pulses generated per kilowatt-hour; the unit is imp / kWh or Imp / kWh or p / kWh.

[0028] The present invention also includes a pulse input counting module, which includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it performs the steps of the pulse input counting method of the special transformer terminal as described above, and then counts the pulses based on the pulse signals sent by the pulse output device and supports the calculation and statistical tasks of related power information.

[0029] The present invention also includes a dedicated transformer terminal that integrates a pulse input counting module as described above, thereby creating an embedded system for counting pulse inputs when the dedicated transformer terminal is in operation.

[0030] The technical solution provided by this invention has the following beneficial effects:

[0031] In traditional pulse detection schemes using scanning sampling, a higher sampling rate generally results in more accurate data. However, each sampling means the MCU is interrupted; a higher sampling rate leads to more frequent MCU interruptions, which affects processing chip performance, increases power consumption, and also reduces the time the chip can spend processing other tasks. This invention utilizes pulse signals to trigger interrupts; it counts the number of pulses by detecting pulse start and end flags and iteratively calculates the pulse interval.

[0032] The interrupt frequency of this novel pulse counting scheme is not affected by the timer, but rather depends on the frequency of the input pulse signal. When the pulse frequency is low, it will not cause an interrupt to the MCU. Therefore, this invention can improve MCU occupancy and power consumption while ensuring the accuracy of the recorded input pulse data.

[0033] In traditional pulse detection schemes using scanning sampling, the sampling time may not coincide with the pulse occurrence time, thus failing to guarantee the most accurate pulse time. In contrast, the pulse time acquired by the scheme of this invention is highly accurate, and the signal processing process is simplified. Attached Figure Description

[0034] Figure 1 This is a flowchart of the pulse input counting method for a special transformer terminal provided in Embodiment 1 of the present invention.

[0035] Figure 2 This is a signal schematic diagram illustrating the interrupt triggering process based on pulse signals in Embodiment 1 of the present invention. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0037] Example 1

[0038] In traditional pulse detection schemes, the transformer terminal continuously generates sampling signals at a preset sampling frequency using a timer, then detects changes in the pulse signal level. When a level change is detected, the corresponding signal state is recorded, and pulse counting is performed based on the signal detection results. In this "scanning" detection method, to ensure the accuracy of the detection results, the sampling signal frequency generated by the timer needs to be high enough. This inevitably leads to frequent interruptions of the MCU, significantly increasing the operating load and power consumption of the transformer terminal. If the sampling signal frequency is reduced, some signal may be lost in the pulse signal detection results, leading to inaccurate pulse counting results.

[0039] Many existing devices use scanning pulse detection schemes, and some new devices also use this traditional detection method. The disadvantages of traditional detection schemes are not obvious when the pulse signal is a high-frequency signal (where there is a high-power load at the power node). However, when the pulse signal is a low-frequency signal, the timer still needs to interrupt the MCU according to the preset sampling frequency and perform pulse signal level detection, which will undoubtedly affect the normal execution of other tasks by the MCU.

[0040] In this embodiment, a novel pulse input counting method is provided that directly interrupts based on the level state of the pulse signal. This method uses the level state of the input pulse signal as the interrupt trigger condition and utilizes an interrupt mechanism to count the pulse inputs. Specifically, as... Figure 1 As shown, the pulse input counting method provided in this embodiment includes the following steps:

[0041] S1: Detect the connection status of the pulse output device so that the dedicated transformer terminal can receive the pulse signal input by the pulse output device.

[0042] Pulse output devices include electricity meters and other measuring devices that use pulses for measurement; the pulse output devices are connected to the dedicated transformer terminal via an RS-485 interface.

[0043] S2: Set the MCU's interrupt trigger condition to the rising and falling edges of the received pulse signal. In this embodiment, the detection of a rising edge is defined as the trigger condition for the interrupt to begin, and the detection of a falling edge is defined as the trigger condition for the interrupt to end.

[0044] S3: Set a preset delay for the start of the interrupt to establish a mechanism for removing signal jitter.

[0045] In this embodiment, considering that the input pulse signal may contain glitches and interference signals, the presence of which may cause the interrupt process to be triggered "erroneously" and frequently, this embodiment sets a delay time when the interrupt is triggered. The interrupt process will only begin if no interrupt is triggered again within a preset delay period after the interrupt triggering condition is met.

[0046] If an interrupt is triggered again within a preset delay period after the interrupt triggering conditions are met, it indicates that the signal that triggered the interrupt previously may have been a glitch or interference signal, rather than a normal pulse. Therefore, in this embodiment, the moment of the re-triggering will be used as the interrupt triggering moment, overriding the previous interrupt handling process, and the system will continue to wait for the next round of delay and judgment.

[0047] S4: Register the interrupt handler process and detect the type of the pulse that triggers the interrupt.

[0048] S5: As Figure 2 As shown, based on the type of pulse detected, the following judgment is made:

[0049] (1) If it is a falling edge, set the pulse start flag to high level and record the time of the falling edge arrival.

[0050] (2) If it is a rising edge, record the pulse end flag and the time of the falling edge arrival, and wait for the interrupt to be triggered again.

[0051] Define the pulse start flag as flagL and the pulse end flag as flagH. In the initial state, flagL = 0 and flagH = 0. When an interrupt is triggered and a falling edge is detected, the pulse start flag is set to 1, i.e., flagL = 1. When an interrupt is triggered and a rising edge is detected, the pulse end flag is set to 1, i.e., flagH = 1.

[0052] S6: Determine whether the pulse start flag and pulse end flag are both high. If so, a complete pulse is detected and the pulses are counted.

[0053] The method for detecting a complete pulse is as follows: after each time the pulse end flag is set to high level (i.e., flagH = 1), check whether the pulse start flag has also been set to high level (i.e., flagL = 1):

[0054] (1) If so, then a complete pulse is detected, the pulse count is incremented by 1, and then the pulse start flag and pulse end flag are reset, i.e., flagL = 0 and flagH = 0.

[0055] (2) If not, then it is determined that the detected pulse is not a complete pulse, the detection result is discarded, and the pulse end flag is reset, that is, flagH = 0.

[0056] S7: Obtain the pulse count value and pulse interval according to the preset sampling period, calculate the pulse power, and complete the power data statistics.

[0057] In this embodiment, the pulse interval t = 1 / f, where the unit is seconds (s), and f represents the pulse frequency, where the unit is Hz. The power statistics tasks completed by the dedicated transformer terminal include: calculating the pulse frequency using the pulse counting results, calculating the average power P based on the pulse constant of the energy meter, and then recording the maximum power value and the time of occurrence for the day and month. The formula for calculating the average power P is as follows:

[0058] P = 3600f / Kp

[0059] In the above formula, Kp is the pulse constant, representing the number of pulses generated per kilowatt-hour, with units of imp / kWh, Imp / kWh, or p / kWh. For example, when the pulse constant is 1000p / kWh, it means that 1000 pulses are generated per kilowatt-hour, that is, every 1000 pulses detected indicates that one kilowatt-hour of electricity has been consumed.

[0060] Example 2

[0061] This embodiment provides a pulse input counting module, which includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it executes the steps of the pulse input counting method of the special transformer terminal as described in Embodiment 1, and then counts the pulses based on the pulse signals sent by the pulse output device, and supports the calculation and statistical tasks of related power information.

[0062] The pulse input counting module provided in this embodiment is essentially a computer device for implementing data processing and instruction generation, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor.

[0063] The embedded data processing module of the computer device provided in this embodiment can also be a smart terminal, tablet computer, laptop computer, desktop computer, rack server, blade server, tower server, or cabinet server (including independent servers or server clusters composed of multiple servers), etc., capable of executing programs. The computer device in this embodiment includes, but is not limited to, a memory and a processor that can be interconnected via a system bus.

[0064] In this embodiment, the memory (i.e., the readable storage medium) includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory may be an internal storage unit of a computer device, such as the hard disk or RAM of the computer device.

[0065] In other embodiments, the memory can also be an external storage device of the computer device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Of course, the memory can also include both internal storage units and external storage devices of the computer device. In this embodiment, the memory is typically used to store the operating system and various application software installed on the computer device. Furthermore, the memory can also be used to temporarily store various types of data that have been output or will be output.

[0066] In some embodiments, a processor may be a central processing unit (CPU), a graphics processing unit (GPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor is typically used to control the overall operation of a computer device. In this embodiment, the processor is used to run program code stored in memory or process data.

[0067] Example 3

[0068] This embodiment also provides a dedicated transformer terminal, which integrates a pulse input counting module as in Embodiment 2, thereby creating an embedded system for counting pulse inputs when the dedicated transformer terminal is running.

[0069] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for counting pulses inputted to a dedicated terminal, characterized by, It uses the level state of the input pulse signal as the interrupt trigger condition and utilizes the interrupt mechanism to count the pulse input; the pulse input counting method includes the following steps: S1: Detect the connection status of the pulse output device so that the dedicated transformer terminal can receive the pulse signal input from the pulse output device; S2: Set the MCU's interrupt trigger condition to the rising and falling edges of the received pulse signal; S3: Set a preset delay for the start of the interrupt to establish a mechanism for removing signal jitter. If no interrupt is triggered again within the preset delay period after the interrupt triggering condition is met, the interrupt process begins. S4: Register the interrupt handling process and detect the type of the pulse that triggers the interrupt; S5: Based on the type of pulse detected, make the following judgment: (1) If it is a falling edge, set the pulse start flag to high level and record the arrival time of the falling edge; (2) If it is a rising edge, set the pulse end flag to high level, record the rising edge arrival time, and wait for the interrupt to be triggered again; S6: Determine whether the pulse start flag and pulse end flag are both high. If so, a complete pulse is detected and the pulses are counted. S7: Obtain the pulse count value and pulse interval according to the preset sampling period, calculate the pulse power, and complete the power data statistics.

2. The method of claim 1, wherein: In step S1, the pulse output device includes an energy meter and other measuring devices that use pulses for measurement; the pulse output device is connected to the dedicated transformer terminal via an RS-485 interface.

3. The method of claim 1, wherein: the number of pulses is counted by a counter. In the MCU interrupt triggering conditions in step S2, a triggering condition is defined as the detection of a rising edge to start an interrupt, and a triggering condition is defined as the detection of a falling edge to end an interrupt.

4. The method of claim 1, wherein the method is performed by a dedicated terminal. In step S3, if an interrupt is triggered again within a preset delay period after the interrupt triggering condition is met, the moment of the re-triggering is taken as the interrupt triggering moment, and the system continues to wait for the next round of delay and judgment.

5. The pulse input counting method for a dedicated transformer terminal as described in claim 1, characterized in that: In step S5, the pulse start flag is defined as flagL and the pulse end flag is defined as flagH. In the initial state, flagL = 0 and flagH = 0. When an interrupt is triggered and a falling edge is detected, the pulse start flag is set to 1, i.e., flagL = 1. When an interrupt is triggered and a rising edge is detected, the pulse end flag is set to 1, i.e., flagH = 1.

6. The method of claim 1, wherein: the pulse input count is a number of pulses input to the dedicated terminal. In step S6, the method for detecting a complete pulse is as follows: after each pulse end flag is set, determine whether the pulse start flag has been set to a high level. (1) If so, then determine that a complete pulse has been detected, count the pulses, and reset the pulse start flag and pulse end flag to low level; (2) If not, it is determined that the detected pulse is not a complete pulse, the detection result is discarded, and the pulse end flag is reset to low level.

7. The method of claim 1, wherein: the pulse input count is a number of pulses input to the dedicated terminal. In step S7, the power statistics tasks completed by the special transformer terminal include: calculating the pulse frequency using the pulse counting results, calculating the average power P based on the pulse constant of the energy meter, and then recording the maximum value and occurrence time of the power on the day and month.

8. The pulse input counting method for a dedicated transformer terminal as described in claim 7, characterized in that: The formula for calculating average power P is as follows: P = 3600f / Kp In the above formula, f represents the pulse frequency in Hz, and Kp is the pulse frequency, which represents the number of pulses generated per kilowatt-hour; the unit is imp / kWh or Imp / kWh or p / kWh.

9. A pulse input counting module characterized by: It includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it performs the steps of the pulse input counting method for the special transformer terminal as described in any one of claims 1-8, and then counts the pulses based on the pulse signals sent by the pulse output device, and supports the calculation and statistical tasks of related power information.

10. A dedicated terminal, characterized by: It integrates a pulse input counting module as described in claim 9, thereby creating an embedded system for counting pulse inputs during the operation of the special transformer terminal.