S-level electric energy quality event annular recording method
By combining event data ring buffers with timer interrupts to collect power data and storing it in partitions according to event type, the problem of excessive resource consumption for S-level power quality event recording in existing technologies is solved, and high-precision power monitoring and analysis are achieved.
Patent Information
- Application Number
- CN202511057971.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-11-14
AI Technical Summary
Existing technologies struggle to achieve millisecond-level recording of S-level power quality events, leading to excessive equipment resource consumption and potential lag or shutdown, thus failing to meet the demands of high-precision power monitoring.
Power data is periodically collected using an event data ring buffer combined with timer interrupts. S-level power quality events are judged through data processing callback functions, and the data is stored in non-volatile memory partitioned by event type. Dynamic expansion and encryption processing are supported to avoid resource consumption.
It achieves high-precision detection and recording of S-level power quality events, avoids equipment lag, meets the requirements of high-quality power monitoring, and has efficient data storage and analysis capabilities.
Smart Images

Figure CN120949997A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power system quality monitoring technology, and specifically to a method for circular recording of S-level power quality events. Background Technology
[0002] Power quality is a comprehensive indicator that describes the ability of a power system to supply electrical energy to a load. Good power quality means that the power system can provide stable electrical energy with a voltage waveform close to the ideal. However, in practical applications, power systems are often affected by various factors, such as lightning, grid faults, nonlinear loads, and power electronic equipment. These factors may cause voltage fluctuations, frequency deviations, harmonic pollution, transient voltage anomalies, and other phenomena, thus affecting power quality.
[0003] Class S power quality events refer to power quality problems in a power system that are of high severity, have significant impact, or require special monitoring technologies. The International Electrotechnical Commission (IEC) standard IEC 61000-4-30 defines a series of power quality measurement parameters, including but not limited to: voltage sags and short-term interruptions, harmonics, voltage fluctuations, flicker, and other transient phenomena (such as surges, spikes, and oscillations). Class S power quality events are widely used for monitoring related to power grid surveys and trend analysis. They are applicable not only to power companies and regulatory agencies but also to large industrial users and electrical equipment manufacturers. By recording Class S power quality events and conducting post-event analysis, stakeholders can more systematically monitor and evaluate power quality, thereby taking measures to improve power system performance, reduce equipment failure rates, and increase production efficiency and product quality.
[0004] Recording S-level power quality events requires continuous and uninterrupted power data acquisition and recording of the power system. Current technologies can typically achieve second-level recording, which meets relevant standards, but struggles to record non-critical parameters (such as interharmonics and high-frequency transients). With increasing demands for high-quality power monitoring, more and more large industrial users and electrical equipment manufacturers are demanding higher precision in parameter monitoring. Simply increasing the recording speed from second-level to millisecond-level would significantly increase the amount of external storage required per unit time, leading to excessive MCU and SRAM resource consumption, causing equipment lag or even shutdowns, and ultimately failing to meet the power quality monitoring needs of the power system. Summary of the Invention
[0005] The purpose of this invention is to provide a circular recording method for S-level power quality events. This method can achieve high-precision detection of S-level power quality events, record events efficiently and without omissions, does not easily occupy hardware resources, does not easily cause lag, and can better meet the needs of high-quality power monitoring.
[0006] To achieve the above objectives, the specific technical solution adopted by the present invention is as follows:
[0007] This invention provides a method for circular recording of S-level power quality events, the method comprising:
[0008] Initialize the timer in the metering module;
[0009] In the application module, create an event data circular buffer, define a data processing callback function, and inject the data processing callback function into the metering module for storage through the registration interface;
[0010] The metering module periodically collects power data based on timer interrupts and calls a data processing callback function to pass the power data to the application module;
[0011] The application module performs S-level power quality event condition judgment. If the power data meets the event triggering conditions, it is enqueued into the event data circular buffer; otherwise, it returns directly. The S-level power quality events include at least one of voltage drop, voltage surge, momentary interruption, and harmonic distortion.
[0012] When the application module checks that the event data circular buffer is not empty, it reads the power data from the read pointer position and writes it to the non-volatile memory. If the check is empty, it returns directly.
[0013] As a preferred embodiment of the present invention, the event data ring buffer adopts a dynamic expansion mechanism, which automatically expands when the remaining space is less than 10%.
[0014] As a preferred embodiment of the present invention, the initialization step includes selecting a clock source and configuring a sampling frequency.
[0015] As a preferred embodiment of the present invention, the power data includes timestamp information for event tracing, the timestamp information being obtained based on satellite synchronization signals.
[0016] As a preferred embodiment of the present invention, the metering module further includes a step of filtering the power data before calling the data processing callback function.
[0017] As a preferred embodiment of the present invention, the method further includes a step of dynamically adjusting the event triggering conditions, specifically: the application module receives external configuration parameters and dynamically modifies the event triggering conditions.
[0018] As a preferred embodiment of the present invention, when the power data is written to the non-volatile memory, it is partitioned and stored according to event type, and an index table is generated. The index table includes event type, timestamp, and storage address.
[0019] As a preferred embodiment of the present invention, when the power data is written to the non-volatile memory, it is encrypted using the AES-256 algorithm of the security module.
[0020] As a preferred embodiment of the present invention, when the application module controls the power data to be enqueued into the event data circular buffer, it synchronously triggers the alarm signal generation module, which generates an alarm signal and automatically sends it to the alarm receiving end.
[0021] In summary, the present invention has the following beneficial effects:
[0022] Traditional methods, with their second-level recording capabilities, can only capture slow trend changes. However, this method can accurately capture voltage drops and transient pulses as short as one power cycle (20ms) through half-cycle RMS updates (10ms level), improving the resolution to the millisecond level. This meets the accuracy requirements for the start / end time of Class S power quality events in IEC 61000-4-30.
[0023] Traditional recording methods only save event IDs. This method, by combining an event data circular buffer with high-speed sampling, can completely record the power data corresponding to S-level power quality events without omissions, and can more effectively assist subsequent power system analysis.
[0024] The method provided by this invention utilizes the data buffering capability of the event data ring buffer to avoid device lag caused by writing a large amount of power data to non-volatile memory at the same time, and is better suited for hardware devices such as microcontrollers with limited resources. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is a flowchart of the method;
[0027] Figure 2 This is a schematic diagram of a specific process in the embodiment. Detailed Implementation
[0028] The subject matter described herein will now be discussed with reference to exemplary embodiments. It should be understood that these embodiments are discussed merely to enable those skilled in the art to better understand and implement the subject matter described herein, and are not intended to limit the scope, applicability, or examples set forth in the claims. The function and arrangement of the elements discussed may be changed without departing from the scope of this specification. Various processes or components may be omitted, substituted, or added as needed in the various examples. For example, the described methods may be performed in a different order than described, and steps may be added, omitted, or combined. Furthermore, features described in some examples may be combined in other examples.
[0029] like Figure 1 and Figure 2 As shown in the figure, this embodiment of the invention provides a method for circular recording of S-level power quality events. The method flow is explained in detail below.
[0030] Initialize the timer in the metering module.
[0031] The metering module is based on a metering chip, which contains a timer. The metering chip initializes the timer by executing a preset program, specifically by selecting a clock source and configuring the sampling frequency.
[0032] During the initialization phase, the metering module needs to initialize the timer and configure the sampling frequency to achieve sampling at fixed time intervals. Since the power grid frequency is generally 50Hz-60Hz, the time length corresponding to each cycle of data is in the range of 16.7-20ms. This embodiment takes the power grid frequency of 50Hz as an example. It can be seen that the time length corresponding to each cycle of data is 20ms. Therefore, the time length corresponding to half-cycle data is 10ms. A 10ms periodic timer is created to collect half-cycle instantaneous quantities, including fundamental wave, full wave voltage and current data.
[0033] Create an event data circular buffer in the application module, define a data processing callback function, and inject the data processing callback function into the metering module for storage through the registration interface.
[0034] During the initialization phase, an event data circular buffer needs to be created in the application module. In this embodiment, an event data circular FIFO is used as the circular buffer to record power data that meets the event triggering conditions. A circular FIFO is a first-in, first-out (FIFO) data structure that uses a fixed-size storage space to achieve cyclic reading and writing of data. Its core feature is that the read / write pointer automatically wraps back to the beginning position at the end of the buffer, forming a circular loop. The application module can be implemented using existing MCU or other processing cores, which include SRAM. Arranging the event data circular FIFO in SRAM enables fast access to power data, and the FIFO order does not affect the order in which power data meeting the event triggering conditions are stored in non-volatile memory or external storage devices.
[0035] After creating the event data ring FIFO, the application module then defines a data processing callback function. A data processing callback function is a function that encapsulates custom data processing logic and passes it to other modules (such as the metering module) through parameters. The module automatically calls the function when specific conditions are met (such as data collection completion or event triggering).
[0036] After the application module defines the data processing callback function, it injects the data processing callback function into the metering module for storage through the registration interface. The metering module is implemented based on the metering chip, and the data processing callback function can be stored in the SRAM of the metering chip.
[0037] Next, the metering module periodically collects power data based on timer interrupts and calls the data processing callback function to pass the power data to the application module.
[0038] The metering module, based on timer interrupts, performs power data acquisition every 10ms. Specifically, the ADC unit in the acquisition chip, triggered by a timer interrupt, converts the analog voltage / current of the monitored power system into digital quantities. The acquisition chip stably captures the voltage / current waveforms within a 10ms period, providing millisecond-level data support for power quality analysis (such as voltage swells / droops and harmonics). The metering module can pass power data to the application module by calling the data processing callback function. Therefore, the determination of whether the acquired power data belongs to a Class S power quality event is not performed in the metering module, but by the application module. This is because the determination of Class S power quality events requires continuous waveform analysis, involves complex algorithms (such as FFT transformation and threshold comparison), and is more dependent on the resource environment of the application module. Furthermore, having the application module perform the determination can significantly reduce the resource consumption of the metering module. The metering module only needs to maintain high-frequency acquisition, avoiding the use of interrupt response time or memory resources for event analysis, thus ensuring the stability of the acquisition.
[0039] The application module performs S-level power quality event condition judgment. If the power data meets the event triggering conditions, it is enqueued into the event data circular buffer; otherwise, it returns directly.
[0040] The judgment of S-level power quality events is based on the event triggering conditions. S-level power quality events include at least one of voltage sag, voltage surge, momentary interruption, and harmonic distortion. Taking voltage surge as an example, in a multiphase system, voltage surge begins when the Urms voltage of any channel rises above the surge threshold and ends when the Urms voltage of all channels is equal to or below the surge threshold minus the hysteresis voltage. Urms is the effective voltage value.
[0041] A voltage surge is characterized by two data points: the maximum surge voltage amplitude and the duration. The maximum surge voltage amplitude is the maximum Urms value measured on any channel during the surge, and the duration is the difference between the start and end times of the voltage surge. The event triggering condition includes a preset value for comparison with the maximum surge voltage amplitude, which can be determined based on a certain percentage (e.g., 10%) above the normal voltage amplitude. It also includes a time threshold to determine the event type of the voltage fluctuation. If a power data point meets the event triggering condition, the application module enqueues the power data point into the event data circular buffer, filling the event data circular FIFO, thus completing the recording of a voltage surge event. The recording format is shown in the table below.
[0042] Table 1 No. Clock Phase Umax Duration 1 2023-09-08 15:33:13 PB 250.03V 760ms … … … … … .
[0043] Wherein, Phase refers to the phase of the voltage surge at the beginning of the voltage surge.
[0044] When the application module checks that the event data circular buffer is not empty, it reads the power data from the read pointer position and writes it to the non-volatile memory. If the check is empty, it returns directly.
[0045] This step corresponds to the event logging task. During the event logging phase, the application module checks the status (empty / non-empty) of the event data ring FIFO to determine whether to read the power data and write it to the non-volatile memory. Through the collaborative design of the event data ring FIFO and the non-volatile memory, real-time performance and resource consumption can be balanced while ensuring data integrity.
[0046] The recording process is complete once the power data (representing S-level power quality events) in the event data ring FIFO is stored in the non-volatile memory.
[0047] In another possible embodiment, the power data includes timestamp information for event tracing, the timestamp information being obtained based on satellite synchronization signals.
[0048] Timestamp information in power data, generated based on satellite synchronization signals, is a core technological support for high-precision event tracing, fault analysis, and coordinated control in power systems. Timestamps based on satellite signals such as BeiDou / GPS achieve microsecond to nanosecond accuracy, enabling data recorded by power equipment in different locations (such as fault recording devices and relay protection units) to have a unified time reference. For example, when a power grid fault occurs, data from multiple endpoints can be aligned based on timestamps to quickly locate the fault point.
[0049] In another possible embodiment, the event data circular buffer adopts a dynamic expansion mechanism, automatically expanding by 50% when the remaining space is less than 10%.
[0050] When the remaining space is less than 10% (i.e., the event data ring FIFO utilization rate is greater than 90%), expansion is triggered. This step is to deal with sudden traffic scenarios (such as power failures). In such cases, for a long period of time, all power data collected by the metering module may be judged as S-level power quality events. At this time, the remaining space of the event data ring buffer will be consumed quickly. After triggering dynamic expansion, it can prevent S-level power quality events from being overwritten due to the buffer being full.
[0051] In another possible embodiment, the application module can also receive external configuration parameters to dynamically modify the event triggering conditions. This allows for adaptive adjustments for different monitored power systems.
[0052] In another possible embodiment, the metering module includes a filtering operation on the power data before calling the data processing callback function. The filtering operation can employ a wavelet transform denoising algorithm, designing a bandpass filter for the 50Hz fundamental frequency to filter out high-frequency noise and low-frequency drift components. This step can eliminate the fundamental signal contaminated by high-order harmonics generated by nonlinear loads (such as rectifiers and frequency converters), reducing the false trigger rate and improving the accuracy of event judgment. In another possible embodiment, when the power data is written to non-volatile memory, it is partitioned and stored according to event type, and an index table is generated. The index table contains the event type, timestamp, and storage address.
[0053] Specifically, when a new type of event (such as a new type of harmonic disturbance) is detected, a partition is automatically created and the metadata table is updated. Each event is stored as an independent data block, containing an event header (type + timestamp) + power data body. The data within the block is sorted by satellite timestamp, and continuous waveform reconstruction is supported.
[0054] In another possible embodiment, when the power data is written to the non-volatile memory, it is encrypted using the AES-256 algorithm of the security module.
[0055] For certain monitored systems, encryption methods are needed to protect business information or user secrets. For example, for some new energy power plant systems, algorithm encryption of power data can prevent the leakage of business information.
[0056] As a preferred embodiment of the present invention, when the application module controls the power data to be enqueued into the event data circular buffer, it synchronously triggers the alarm signal generation module, which generates an alarm signal and automatically sends it to the alarm receiving end.
[0057] The alarm signal generation module can be placed in the application module or outside the application module. When an enqueue operation occurs in the event data circular buffer, the alarm signal generation module generates an alarm signal and automatically sends it to the alarm receiver. The alarm receiver can be the power grid remote monitoring center or the mobile device of the operation and maintenance personnel. The purpose is to help the monitoring party grasp the power system information in real time.
[0058] The following code demonstrates the recording process for an S-level power quality event.
[0059] 1. Data Collection
[0060] (1) Create a half_wave_sample structure. The metering APP will fill the sampled power data into the structure every 10ms.
[0061] (2) Callback injection function.
[0062] 2. Data Analysis
[0063] (1) Create a voltage surge data FIFO structure fifo_data.
[0064] struct swell_fifo_data_t
[0065] {
[0066] uint8_t start_time
[12] ;
[0067] uint8_t start_ms;
[0068] uint8_t start_phase;
[0069] uint16_t umax;
[0070] uint32_t duration_ms;
[0071] };
[0072] struct fifo_data_t
[0073] {
[0074] struct swell_fifo_data_t swell_fifo_data
[50] ;
[0075] volatile uint8_t rd;
[0076] volatile uint8_twd;
[0077] fifo_data;
[0078] (2) The callback function determines whether the half_wave_sample data meets the voltage surge condition. If it does, it updates start_time, start_ms, and start_phase in swell_fifo_data.
[0079] (3) The callback function continuously checks whether the half_wave_sample data meets the voltage surge condition. If it changes from meeting the condition to not meeting it, it updates the umax and duraion_ms for the duration.
[0080] (4) The above (2) and (3) are updated, that is, swell_fifo_data is filled once and wd is increased by 1.
[0081] (5) When swell_fifo_data is filled 50 times, wd is set to 0. Filling swell_fifo_data forms a circular FIFO, which is first-in, first-out.
[0082] 3. Event Log
[0083] (1) When the application circle task is detected, if the swell_fifo_data corresponding to rd is empty, it is not recorded; otherwise, proceed to (2).
[0084] (2) Extract swell_fifo_data one by one, frame DLMS event record standard format, write to external storage device, clear the current swell_fifo_data, record one event per lap and exit immediately, and increment rd by 1.
[0085] (3) Increase rd by 50, then set rd to 0. The swell_fifo_data is read out to form a circular FIFO, which is first-in, first-out.
[0086] Several embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, and are not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical applications, or technological improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method for circular recording of S-level power quality events, characterized in that, The methods include: Initialize the timer in the metering module; In the application module, create an event data circular buffer, define a data processing callback function, and inject the data processing callback function into the metering module for storage through the registration interface; The metering module periodically collects power data based on timer interrupts and calls a data processing callback function to pass the power data to the application module; The application module performs S-level power quality event condition judgment. If the power data meets the event triggering conditions, it is enqueued into the event data circular buffer; otherwise, it returns directly. The S-level power quality events include at least one of voltage drop, voltage surge, momentary interruption, and harmonic distortion. When the application module checks that the event data circular buffer is not empty, it reads the power data from the read pointer position and writes it to the non-volatile memory. If the check is empty, it returns directly.
2. The method for circular recording of S-level power quality events according to claim 1, characterized in that, The event data circular buffer adopts a dynamic expansion mechanism, which automatically expands when the remaining space is less than 10%.
3. The method for circular recording of S-level power quality events according to claim 1, characterized in that, The initialization steps include selecting a clock source and configuring the sampling frequency.
4. The method for circular recording of S-level power quality events according to claim 1, characterized in that, The metering module performs filtering operations on the power data before calling the data processing callback function.
5. The method for circular recording of S-level power quality events according to claim 1, characterized in that, This method also includes a step of dynamically adjusting the event triggering conditions, specifically: the application module receives external configuration parameters and dynamically modifies the event triggering conditions.
6. The method for circular recording of S-level power quality events according to claim 1, characterized in that, The power data includes timestamp information for event tracing, which is obtained based on satellite synchronization signals.
7. The method for circular recording of S-level power quality events according to claim 6, characterized in that, When the power data is written to the non-volatile memory, it is partitioned and stored according to event type, and an index table is generated. The index table contains event type, timestamp, and storage address.
8. The method for circular recording of S-level power quality events according to claim 7, characterized in that, When the power data is written to the non-volatile memory, it is encrypted using the AES-256 algorithm of the security module.
9. The method for circular recording of S-level power quality events according to claim 1, characterized in that, When the application module controls the enqueueing of power data into the event data circular buffer, it synchronously triggers the alarm signal generation module, which generates an alarm signal and automatically sends it to the alarm receiving end.