Electric energy quality monitoring device and equally-spaced sampling method
By integrating the event capture module and the PWM generation module in the MCU, the period of the power frequency signal is captured in real time and the period of the sampling pulse is adjusted, which solves the problem of difficulty in real-time tracking of the power frequency signal frequency in the prior art, and achieves equal interval sampling and high Accurate power harmonic analysis.
Patent Information
- Application Number
- CN202411467949.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-02-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art is difficult to track the frequency changes of the power frequency signal in real time in power systems, resulting in uneven sampling intervals and affecting the accuracy of power harmonic analysis.
By integrating the event capture module and the PWM generation module in the MCU, the PWM0 capture mode and the PWM2 output mode are used to capture the period of the power frequency signal in real time and adjust the period of the sampling pulses to achieve equally spaced sampling.
The method of tracking the frequency of the power frequency signal in real time and performing equally spaced sampling without adding external hardware circuits is realized, which improves the accuracy of power harmonic analysis.
Smart Images

Figure CN119395412A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of electronic measurement, in particular to a power quality monitoring device and an equal-interval sampling method. Background Art
[0002] Today, the relay protection and automatic devices of power systems generally use AC sampling, which is converted into digital signals through AD, and then processed by MCU (microcontroller unit) to complete various specific relay protection functions. When AC sampling of 50Hz power frequency signals is performed, fixed frequency sampling signals are generally used, which can truly reflect the waveform time domain information of the original signal. However, when it is necessary to perform frequency domain analysis on power frequency signals, such as harmonic content calculation, due to the slight changes in the frequency of the power frequency signal, if fixed frequency sampling is used at this time, the Fourier transform, a mathematical tool for frequency domain analysis, will have leakage effects, thereby affecting the accuracy of harmonic analysis. This requires that when monitoring power harmonics, the intervals of the sampling signals should be evenly distributed within the power frequency cycle of a sampling object, and this sampling interval can track the slight changes in the frequency of the power frequency signal in real time and adjust the changes in time. In the past, the above functions were realized by building a frequency multiplication hardware circuit with the help of a phase-locked loop, and due to the limitations of the hardware frequency multiplication principle, only 2n frequency multiplication sampling can be achieved.
[0003] Since almost all MCUs have timers and counters, frequency measurement in devices with MCUs uses the method of counting timer clock pulses within a specific period to obtain the period of the measured signal and thus the frequency value. The higher the clock frequency, the higher the accuracy of the measured period value and frequency value. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a power quality monitoring device and an equal-interval sampling method, which can realize real-time tracking of the power frequency signal and perform equal-interval sampling without adding external hardware circuits.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0006] A power quality monitoring device comprises an MCU, wherein the MCU is integrated with an event capture module and a PWM generation module, wherein the PWM generation module comprises a PWM01 logic module and a PWM23 logic module, wherein the PWM0 PIN pin of the PWM generation module is connected to an industrial frequency signal, and the PWM2 PIN pin outputs a sampling pulse for sampling control by an A / D circuit.
[0007] A method for equally spaced sampling of a power quality monitoring device comprises the following steps:
[0008] S1, initialize the relevant functions in MCU, so that the PWM01 logic module obtains the capture function, and the PWM23 logic module obtains the PWM output function;
[0009] S2, initialize MCU settings, disable PWM interrupts, and allow the PWM01 module capture function to generate interrupts;
[0010] S3, setting the PWM2 output mode to a continuous cycle output mode, and setting the initial cycle value and duty cycle of the output waveform;
[0011] S4, set the PWM0 capture mode;
[0012] S5, start PWM2 to start working, and output continuous sampling pulses according to the initial value;
[0013] S6, start the capture function of PWM0 to start working;
[0014] S7, capture interrupt, read the capture time of the input signal, calculate the period of the power frequency signal and update the period of the sampling pulse in real time.
[0015] A further improvement of the technical solution of the present invention is that in S4, it is set to capture the rising edge of the input signal.
[0016] A further improvement of the technical solution of the present invention is that: in S7, the rising edge time T of the input signal is read n , T n-1 The last rising edge capture moment;
[0017] The period value of the input signal T = T n -T n-1 ;
[0018] The period value of the sampling pulse is T / N, where N is the number of sampling points per power frequency cycle of the device;
[0019] Modify the sampling pulse period of PWM output according to T / N.
[0020] A further improvement of the technical solution of the present invention is that in S4, the rising edge and the falling edge of the input signal are set to generate capture.
[0021] A further improvement of the technical solution of the present invention is that: in S7, the rising edge and falling edge time T' of the input signal are read n , T′ n-1 Capture the moment of the last rising or falling edge;
[0022] The period value of the input signal T' = T' n -T′ n-1 ;
[0023] The period value of the sampling pulse is T' / N, where N is the number of sampling points per power frequency cycle of the device;
[0024] Modify the sampling pulse period of PWM output according to T' / N.
[0025] Due to the adoption of the above technical solution, the technical progress achieved by the present invention is:
[0026] 1. The present invention utilizes the internal peripheral resources of the MCU to track the frequency of the power frequency signal in real time and perform equal-interval sampling without adding external hardware circuits.
[0027] 2. The present invention can set the capture function to capture both the rising and falling edges, so that the sampling pulse period value is corrected once every half input signal period, and the real-time tracking performance will be further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a sampling principle diagram of the present invention. DETAILED DESCRIPTION
[0029] The present invention is further described in detail below with reference to the accompanying drawings and embodiments:
[0030] like Figure 1 As shown in the figure, the basis for equal-interval sampling is to obtain the actual frequency X of the power frequency signal in real time, and adjust the frequency of the sampling pulse to N*X in real time, where N is the number of samples per cycle. Repeated cycles can achieve real-time tracking of the actual frequency of the sampled signal by the sampling frequency, thereby achieving the purpose of evenly distributing the sampling pulses within the period range of the adopted signal. The real-time performance of sampling pulse frequency tracking depends on the speed of frequency measurement.
[0031] A power quality monitoring device comprises an MCU, wherein the MCU is integrated with an event capture module and a PWM generation module; the PWM generation module comprises a PWM01 logic module and a PWM23 logic module, the PWM0 PIN pin of the PWM generation module is connected to an industrial frequency signal, and the PWM2 PIN pin outputs a sampling pulse for sampling control by an A / D circuit.
[0032] Example 1
[0033] A method for equally spaced sampling of a power quality monitoring device comprises the following steps:
[0034] S1, initialize the relevant functions in MCU, so that the PWM01 logic module obtains the capture function, and the PWM23 logic module obtains the PWM output function;
[0035] S2, initialize MCU settings, disable PWM interrupts, and allow the PWM01 module capture function to generate interrupts;
[0036] S3, setting the PWM2 output mode to a continuous cycle output mode, and setting the initial cycle value and duty cycle of the output waveform;
[0037] S4, set the PWM0 capture mode to capture the rising edge of the input signal;
[0038] S5, start PWM2 to start working, and output continuous sampling pulses according to the initial value;
[0039] S6, start the capture function of PWM0 to start working;
[0040] S7, capture interrupt, read the rising edge time T of the input signal n ; Calculate the period of the power frequency signal and update the period of the sampling pulse in real time:
[0041] The period value of the input signal T = T n -T n-1 , T n-1 The last rising edge capture moment;
[0042] The period value of the sampling pulse is T / N, where N is the number of sampling points per power frequency cycle of the device;
[0043] Modify the sampling pulse period of PWM output according to T / N.
[0044] Example 2
[0045] A method for equally spaced sampling of a power quality monitoring device comprises the following steps:
[0046] S1, initialize the relevant functions in MCU, so that the PWM01 logic module obtains the capture function, and the PWM23 logic module obtains the PWM output function;
[0047] S2, initialize MCU settings, disable PWM interrupts, and allow the PWM01 module capture function to generate interrupts;
[0048] S3, setting the PWM2 output mode to a continuous cycle output mode, and setting the initial cycle value and duty cycle of the output waveform;
[0049] S4, set the PWM0 capture mode to capture the rising and falling edges of the input signal;
[0050] S5, start PWM2 to start working, and output continuous sampling pulses according to the initial value;
[0051] S6, start the capture function of PWM0 to start working;
[0052] S7, capture interrupt, read the rising and falling edge time T' of the input signaln ; Calculate the period of the power frequency signal and update the period of the sampling pulse in real time:
[0053] The period value of the input signal T' = T' n -T′ n-1 , T′ n-1 Capture the moment of the last rising or falling edge;
[0054] The period value of the sampling pulse is T' / N, where N is the number of sampling points per power frequency cycle of the device;
[0055] Modify the sampling pulse period of PWM output according to T' / N.
[0056] Example 3
[0057] The following uses the Allwinner T3 chip as an example to illustrate how to obtain the period value of the power frequency signal.
[0058] The industrial frequency signal is connected to the PWM0 PIN of the T3 chip; the PWM2 PIN outputs sampling pulses for the A / D circuit to perform sampling control.
[0059] Initialization process
[0060] Write the corresponding value to the PWM-ENABLE-REG register of T3 and set the PWM01 logic module to the capture function;
[0061] Write the corresponding value to the CAPTURE-ENABLE-REG register to set the PWM23 logic module to the PWM output function.
[0062] Write the corresponding value to the PWM-IRQ-ENABLE-REG register to disable PWM interrupt;
[0063] Write the corresponding value to the CAPTURE-IRQ-ENABLE-REG register to allow the PWM01 module capture function to generate interrupts;
[0064] Write the corresponding value to the PWM-CTR-REG register to set PWM2 to continuous cycle output mode;
[0065] Write the corresponding value to the PWM-PERIOD-REG register to set the initial period value and duty cycle of the PWM2 output waveform;
[0066] Write the corresponding value to the CAPTURE-CTR-REG register and set it to capture the rising edge of the PWM0 input signal;
[0067] Write the corresponding value to the PWM-ENABLE-REG register, start PWM2 to start working, and output continuous sampling pulses according to the initial value;
[0068] Write the corresponding value to the CAPTURE-ENABLE-REG register to start the capture function of PWM0.
[0069] The capture interrupt service routine includes:
[0070] Read the CAPTURE-RISE-REG register. This value is the rising edge time T of the input signal. n ,
[0071] At this time, the period value of the input signal is T = T n -T n-1 , T n-1 The last rising edge capture moment;
[0072] The period value of the sampling pulse is T / N, where N is the number of sampling points per power frequency cycle of the device;
[0073] Write T / N into the PWM-PERIOD-REG register to modify the sample pulse period of the PWM output;
[0074] Working principle:
[0075] Each time a capture interrupt is generated, the actual measurement period value of each input power frequency signal period will be obtained in real time, and the period of the sampling pulse will be modified in real time based on this value, so that the period of the sampling pulse can track the period change of the input signal in real time, achieving the purpose of equal-interval sampling.
[0076] In addition, in order to facilitate fast Fourier transform during data processing, the number of sampling points is generally set to N = 2 n , then the calculation of T / N can be realized in a fast way by shifting T right by n.
Claims
1. A power quality monitoring device, comprising an MCU, wherein the MCU is integrated with an event capture module and a PWM generation module, characterized in that: The PWM generation module includes a PWM01 logic module and a PWM23 logic module. The PWM0 PIN pin of the PWM generation module is connected to the industrial frequency signal, and the PWM2 PIN pin outputs a sampling pulse for the A / D circuit to perform sampling control.
2. A method for sampling at equal intervals in a power quality monitoring device, characterized in that: Using the power quality monitoring device as claimed in claim 1 comprises the following steps: S1, initialize the relevant functions in MCU, so that the PWM01 logic module obtains the capture function, and the PWM23 logic module obtains the PWM output function; S2, initialize MCU settings, disable PWM interrupts, and allow the PWM01 module capture function to generate interrupts; S3, setting the PWM2 output mode to a continuous cycle output mode, and setting the initial cycle value and duty cycle of the output waveform; S4, set the PWM0 capture mode; S5, start PWM2 to start working, and output continuous sampling pulses according to the initial value; S6, start the capture function of PWM0 to start working; S7, capture interrupt, read the capture time of the input signal, calculate the period of the power frequency signal and update the period of the sampling pulse in real time.
3. The equal-interval sampling method for a power quality monitoring device according to claim 2 is characterized in that: In S4, it is set that the rising edge of the input signal generates capture.
4. The equal-interval sampling method for a power quality monitoring device according to claim 3 is characterized in that: In S7, read the rising edge time T of the input signal n , T n-1 The last rising edge capture moment; The period value of the input signal T = T n -T n-1 ; The period value of the sampling pulse is T / N, where N is the number of sampling points per power frequency cycle of the device; Modify the sampling pulse period of PWM output according to T / N.
5. The equal-interval sampling method for a power quality monitoring device according to claim 2 is characterized in that: In S4, it is set that the rising edge and falling edge of the input signal are captured.
6. The equal-interval sampling method for a power quality monitoring device according to claim 5 is characterized in that: In S7, read the rising and falling edge times T' of the input signal n , T′ n-1 Capture the moment of the last rising or falling edge; The period value of the input signal T' = T' n -T′ n-1 ; The period value of the sampling pulse is T ′ / N, N is the number of sampling points per power frequency cycle of the device; According to T ′ / N modifies the sampling pulse period of PWM output.
Citation Information
Patent Citations
Uniformly-spaced sampling circuit and sampling method for different frequency signals
CN102590606A