A method and apparatus for improving the accuracy of fundamental wave measurement
By using a UART module and pipeline to calculate the RCH frequency offset and adjust the bandpass filter coefficients, the problem of insufficient fundamental wave measurement accuracy in existing technologies is solved, achieving high-precision measurement and automatic adjustment of the fundamental wave signal, and reducing hardware costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU VANGO TECH
- Filing Date
- 2023-08-03
- Publication Date
- 2026-05-26
AI Technical Summary
Existing technologies cannot effectively filter out interference signals with frequencies lower than the fundamental frequency in the power grid when filtering out harmonics, and cannot compensate in real time for the impact of sampling frequency offset on the amplitude-frequency characteristics of the filter, resulting in insufficient fundamental frequency measurement accuracy.
The clock signal is sent to the calculation module via a UART module. The RCH frequency offset is calculated in a pipeline manner and the bandpass filter coefficient is adjusted. Combined with the moving average method, the bandpass filter coefficient is corrected in real time to improve the fundamental frequency measurement accuracy.
It achieves high-precision measurement of fundamental current, voltage phase, frequency, and RMS value, reduces hardware costs, and can automatically adjust in real time, thus improving the accuracy of fundamental signal restoration.
Smart Images

Figure CN116953347B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method and apparatus for improving metrological accuracy, specifically a method and apparatus for improving fundamental wave metrological accuracy. Background Technology
[0002] With the increasing intelligence of power grids, related smart grid services are showing a demand for electricity metering functions. The lowest frequency of periodically changing voltage or current in a power network is the fundamental frequency. my country's power grid stipulates a fundamental frequency of 50 Hz, while signals with frequencies other than integer multiples of the fundamental frequency are called harmonics. Harmonics have a significant impact on the accuracy of electricity meter readings; therefore, harmonics need to be filtered out when metering the fundamental frequency. The most common method for filtering harmonics is to input the full-wave signal into a BPF (Band Pass Filter) with a center frequency of 50 Hz. The filtered signal is the fundamental frequency. The coefficients of the BPF are related to the system clock. When using a design without an external crystal oscillator, the RCH (Resistance Capacitance High Speed Internal Clock Signal) is usually used as the system clock. Since the RCH is affected by external temperature, its frequency will also change. If the coefficients of the BPF do not change with the system clock, the fundamental signal obtained through the BPF will have a certain degree of distortion.
[0003] Existing technologies still have shortcomings in solving the above problems, for example:
[0004] Patent document 1: Smart meter with fundamental frequency metering function and its measurement method, CN103852637B. This document uses a low-pass filter to process voltage and current signals in order to filter out harmful harmonics in the power grid, thus reducing the interference of harmonics on fundamental frequency metering. However, using only a low-pass filter cannot filter out some interference signals in the power grid with frequencies lower than the fundamental frequency. Furthermore, it does not consider the impact of sampling frequency offset on the amplitude-frequency characteristics of the filter.
[0005] Patent document 2: A method for measuring the frequency of an input signal and related components, CN110007144A. This document determines the RCH clock frequency through communication frames sent by the MCU, and then calculates the frequency of the input signal based on the known RCH clock frequency. Furthermore, it can compensate for reactive power based on the actual RCH clock frequency. However, the calculated input signal frequency can only be the full-wave frequency; it cannot obtain the fundamental frequency, nor can it compensate for other characteristic parameters of the fundamental wave, such as RMS and phase. Summary of the Invention
[0006] Purpose of the invention: The technical problem to be solved by the present invention is to provide a method and apparatus for improving the accuracy of fundamental wave measurement, in order to address the shortcomings of the prior art.
[0007] To address the aforementioned technical problems, this invention discloses a method and apparatus for improving fundamental frequency measurement accuracy. Specifically, an apparatus for improving fundamental frequency measurement accuracy includes:
[0008] The UART module is used to transmit the number of clock cycles required to send one symbol. The data is sent to the computing module and the control module.
[0009] The calculation module is used to calculate the frequency offset of the RCH and, based on the frequency offset of the RCH, to calculate the bandpass filter coefficients in the fundamental frequency metering device using a pipelined approach. According to the bandpass filter coefficients Adjust the bandpass filter;
[0010] A control module is used for process control in the pipeline mode.
[0011] Registers are used to receive and store relevant data during the operation of the UART module, computing module, and control module.
[0012] Furthermore, the frequency offset value of the calculated RCH is... That is, based on the number of clock cycles sent by the UART module. The calculations are performed, and the specific methods include:
[0013]
[0014] in, The preset baud rate, This refers to the system frequency.
[0015] Furthermore, the bandpass filter coefficients The calculation methods include:
[0016]
[0017] in, The center frequency of the bandpass filter. For another coefficient, ;
[0018] When there is a frequency offset in the RCH, the bandpass filter coefficients The calculation method is as follows:
[0019]
[0020] After simplification and first-order linear fitting, the bandpass filter coefficients were finally obtained. ,as follows:
[0021]
[0022] in, yes , This indicates the coefficients currently stored in the register. The value, It is expressed as the average frequency offset.
[0023] Furthermore, the calculation module only includes multipliers and adders.
[0024] Furthermore, the calculation module employs a pipelined approach to calculate the bandpass filter coefficients. The specific method is as follows:
[0025] Step S1: Use a multiplier to convert the preset baud rate. Multiply by the number of clocks ;
[0026] Step S2: Using a multiplier, the result obtained in step S1 is multiplied by the reciprocal of the theoretical frequency value of RCH to obtain the frequency offset value of RCH. ;
[0027] Step S3: Use a multiplier to convert the frequency offset value of RCH obtained in step S2. Multiply by the constant -2.005;
[0028] Step S4: Using an adder, add the constant 3.005 to the result obtained in step S3, and then set the result... Save to register;
[0029] Step S5: Use the adder to convert the coefficients stored in the previous register. Plus ;
[0030] Step S6, use the multiplier to... Multiply by the result obtained in step S5;
[0031] Step S7, using an adder, to Adding the result from step S6, we obtain the bandpass filter coefficients. , the coefficient Store in register instead .
[0032] Furthermore, the aforementioned method based on clock count Calculate the frequency offset of the RCH. When this is the case, the moving average method is used.
[0033] Furthermore, the average frequency offset is obtained using the moving average method. The calculation method is as follows:
[0034]
[0035] Where N is the length of the sliding window, and L is the coordinate of the current starting position of the sliding window. For the first in the sliding window Individual frequency offset value.
[0036] Furthermore, the value of the coefficient currently stored in the register is mentioned. The method for calculating its first initial value is as follows:
[0037] The center frequency of the bandpass filter With system frequency Substitute into the bandpass filter coefficient b when there is no frequency offset Formula, to obtain the initial The value of .
[0038] Furthermore, the center frequency of the bandpass filter With system frequency The preset is based on the actual environment of the fundamental wave measurement.
[0039] The present invention also proposes a method for improving the accuracy of fundamental frequency measurement, which employs the above-mentioned device for improving the accuracy of fundamental frequency measurement and includes the following steps:
[0040] Step 1: Using the UART module, determine the number of clock cycles required to transmit one symbol using a baud rate adaptive method. Send it to the computing module;
[0041] Step 2: The calculation module calculates the bandpass filter coefficients in the fundamental frequency metering device. And save the coefficient to a register;
[0042] Step 3, based on the bandpass filter coefficients The bandpass filter in the fundamental wave metering device is adjusted and then measured.
[0043] Beneficial effects:
[0044] 1. This invention provides an algorithm that can improve the measurement accuracy of the phase, frequency, and effective value of fundamental current and voltage. The algorithm is easy to implement in hardware, can be integrated into a chip, and can be automatically adjusted in real time.
[0045] 2. This invention derives the actual RCH frequency through a UART baud rate adaptive module (UART, Universal Asynchronous Receiver and Transmitter), and then compares it with the theoretical RCH frequency to obtain the RCH frequency offset. Finally, the coefficients of the BPF are recalculated based on this frequency offset, which can restore the fundamental signal to a greater extent and extract more accurate and higher-precision characteristic parameters, such as phase, frequency, and RMS value.
[0046] 3. This invention simplifies the above method through derivation, enabling it to be implemented using adders and multipliers with lower hardware costs. Furthermore, it employs a pipelined approach to reuse adders and multipliers, further reducing the hardware cost of implementing the algorithm. Attached Figure Description
[0047] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments, and the advantages of the present invention in the above and / or other aspects will become clearer.
[0048] Figure 1 This is a schematic diagram of the fitting error curve of the second-order Taylor expansion of y=cos(z).
[0049] Figure 2a This is a schematic diagram of a first-order linear fit.
[0050] Figure 2b This is a schematic diagram of the fitting error.
[0051] Figure 3 This is a block diagram of the overall solution of the present invention. Detailed Implementation
[0052] This invention provides a method and apparatus for improving the accuracy of fundamental wave measurement. Specifically, it is a method and its hardware implementation for improving the measurement accuracy of the phase, frequency, and effective value of fundamental wave current and voltage when no external crystal oscillator is used and an internal RCH clock is employed.
[0053] One method that can improve the accuracy of fundamental wave measurement is derived as follows:
[0054] The formula for calculating the frequency offset of RCH is:
[0055]
[0056] In the formula, baud_rate is the baud rate, which the user needs to configure in the register first, and baud_cnt is the number of clock cycles required for the baud rate adaptive module to send one code. This is the system frequency, which is equal to the theoretical value of the RCH frequency.
[0057] Here, a second-order elliptic bandpass filter is selected, and its prototype transfer function is:
[0058]
[0059] coefficients in the formula The coefficient b is:
[0060]
[0061] In the formula Let RCH be the center frequency of the bandpass filter, chosen here as the fundamental frequency. As the temperature changes, the frequency of RCH also changes accordingly. Substituting the frequency offset of RCH into the above equation, we obtain the coefficient b as:
[0062]
[0063] Implementing the cos() function directly in hardware is very costly, so it needs to be simplified. According to the Taylor expansion formula of the cosine function, we have:
[0064]
[0065] Substituting the second-order Taylor expansion formula, we get:
[0066]
[0067] When the temperature varies from -40 to 125 degrees Celsius, the RCH frequency shifts by ±4% due to temperature, i.e., bias ∈ [0.96, 1.04]. Let:
[0068]
[0069] Here, f0 = 50Hz, f s Taking 12.8 kHz as an example, we get z ∈ [0.02360, 0.02557]. An error analysis is performed on the second-order cosine Taylor expansion, and the results are as follows: Figure 1 As shown.
[0070] read Figure 1 It can be seen that the maximum error is Choosing a second-order Taylor expansion and substituting it into the bandpass filter coefficient calibration formula, we get:
[0071]
[0072] To further simplify the calculation, Let it be m, and Let it be denoted as n, then
[0073]
[0074] If we denote the value of b in the register as b0, then:
[0075]
[0076] Substituting b0 into the expression for b, we get:
[0077]
[0078] Through the above transformation, the expression for coefficient b no longer contains the frequency values f0 and f s This facilitates the expansion of its applications; for example, in some countries, the fundamental frequency is 60Hz, while f... s The frequency can also be user-defined. The above expression requires a divider, but implementing a divider directly in hardware is very costly. Therefore, a first-order linear fitting method is used to approximate the expression. This function, and when it passes through the point (1,1), i.e., when no frequency offset occurs, has b=b0. Its fitted line is as follows: Figure 2a As shown, Figure 2b For error analysis, as shown in Figure 2, the maximum error is -0.5%, which was obtained when bias=1.04.
[0079] The final expression for b is:
[0080]
[0081] As shown in this expression, the coefficient 'b' of the bandpass filter can be corrected in real time according to the frequency offset of the system. Therefore, the fundamental signal obtained through the corrected bandpass filter has higher accuracy. Taking the effective value as an example, the formula for calculating the effective value of n consecutive signals is:
[0082]
[0083] Where x i The amplitude of the signal obtained after passing through the bandpass filter is higher than that of the bandpass filter designed in this invention. Since the bandpass filter can adapt to the system frequency, its amplitude-frequency characteristics are better and the accuracy of the signal amplitude is higher, so the accuracy of the obtained effective value will also be higher.
[0084] The above scheme obtains the frequency offset of the current clock based on the UART baud rate adaptive module, and then reflects this frequency offset into the coefficients of the bandpass filter. This can restore the fundamental signal to a greater extent, thereby improving the measurement accuracy of frequency, phase, and RMS value. However, the hardware cost of directly implementing this algorithm is very high. This invention simplifies the algorithm through derivation, making it implementable based on adders and multipliers with lower hardware costs. Furthermore, it adopts a pipelined approach to reuse adders and multipliers, further reducing the hardware cost of implementing the algorithm.
[0085] This invention also proposes a device that can improve the accuracy of fundamental wave measurement, the overall scheme of which is as follows:
[0086] like Figure 3 As shown, the overall plan is divided into four parts:
[0087] 1. UART module: This module, through baud rate adaptation, can send baud_cnt, i.e., the number of clock cycles required to send one symbol, to the calculation module, and at the same time, it will also send a valid signal to the control module.
[0088] 2. The calculation module, based on the expression for b, requires an adder (subtraction is implemented using addition) and a multiplier to calculate b. The calculation module performs the addition and multiplication calculations to obtain the final b, which is then sent to the register.
[0089] 3. Registers: On the one hand, registers send b0 and baud_rate to the calculation module, and on the other hand, they receive b from the calculation module.
[0090] 4. Control Module: To save hardware resources, the adder and multiplier are pipelined. The control module controls the pipeline; the pipeline starts when the UART sends a valid signal to the control module. The control module also generates a register write signal to indicate when b is written to the register.
[0091] The computation module employs a pipelined design, as detailed below:
[0092] The first step is to use a multiplier to multiply baud_rate by baud_cnt.
[0093] The second step involves using a multiplier to multiply the result obtained in the first step by the reciprocal of the theoretical RCH frequency value. This step yields the frequency offset value, bias.
[0094] The third step is to use a multiplier to multiply the bias obtained in the second step by a constant -2.005.
[0095] Fourth step: Use an adder to add the constant 3.005 to the result obtained in the third step, and save the result to register r0.
[0096] Fifth step, use the adder to add -m to b0.
[0097] Step 6: Use a multiplier to multiply r0 by the result obtained in step 5.
[0098] In the seventh step, use an adder to add the result obtained in the sixth step to m. This step yields the final coefficient b.
[0099] As shown in Table 1, the pipeline design of the control module reuses adders and multipliers.
[0100] Table 1 Production Line Design
[0101]
[0102] In addition, in some embodiments, the following methods may also be used:
[0103] 1. When calculating the RCH frequency offset, a moving average method can be used to reduce the error caused by the UART baud rate adaptation, thereby further improving the accuracy of fundamental frequency measurement.
[0104] 2. In addition to using the UART baud rate adaptive module to obtain the RCH frequency offset value, the temperature change can also be obtained through a temperature sensor and then converted into the RCH frequency offset value.
[0105] 3. The algorithm uses first-order linear fitting to implement division. In addition, division can also be implemented by multi-order linear fitting, which will have higher accuracy, but the pipeline will be more complex and the implementation cost will be higher.
[0106] 4. In addition to reusing adders and multipliers in a pipelined manner, adders and multipliers themselves can also be converted from single-cycle operations to multi-cycle operations through pipelined methods, thereby further reducing implementation costs.
[0107] In its specific implementation, this application provides a computer storage medium and a corresponding data processing unit. The computer storage medium is capable of storing a computer program, which, when executed by the data processing unit, can run the invention's content regarding a method and apparatus for improving fundamental frequency measurement accuracy, as well as some or all of the steps in various embodiments. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0108] Those skilled in the art will clearly understand that the technical solutions in the embodiments of the present invention can be implemented using computer programs and their corresponding general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of computer programs, i.e., software products. These computer program software products can be stored in a storage medium and include several instructions to cause a device containing a data processing unit (which may be a personal computer, server, microcontroller, MUU, or network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments of the present invention.
[0109] This invention provides a method and apparatus for improving the accuracy of fundamental frequency measurement. Many methods and approaches exist for implementing this technical solution; the above description is merely a preferred embodiment. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications should also be considered within the scope of protection of this invention. All components not explicitly stated in this embodiment can be implemented using existing technologies.
Claims
1. A device for improving the accuracy of fundamental frequency measurement, characterized in that, include: The UART module is used to transmit the number of clock cycles required to send one symbol. The data is sent to the computing module and the control module. The calculation module is used to calculate the frequency offset of the RCH and, based on the RCH frequency offset, to calculate the bandpass filter coefficients in the fundamental frequency metering device using a pipelined approach. According to the bandpass filter coefficients Adjust the bandpass filter; A control module is used for process control in the pipeline mode; Registers are used to receive and store relevant data during the operation of the UART module, computing module, and control module. Among them, the bandpass filter coefficients The calculation methods include: ; in, The center frequency of the bandpass filter. For another coefficient, ; When there is a frequency offset in the RCH, the bandpass filter coefficients The calculation method is as follows: ; After simplification and first-order linear fitting, the bandpass filter coefficients were finally obtained. ,as follows: ; in, yes , This indicates the coefficients currently stored in the register. The value, It is expressed as the average frequency offset.
2. The device for improving fundamental frequency measurement accuracy according to claim 1, characterized in that, The frequency offset value of the RCH is calculated as described above. That is, based on the number of clock cycles sent by the UART module. The calculations are performed using the following methods: ; in, The preset baud rate, This refers to the system frequency.
3. The device for improving fundamental frequency measurement accuracy according to claim 2, characterized in that, The calculation module includes only multipliers and adders.
4. The device for improving fundamental frequency measurement accuracy according to claim 3, characterized in that, The calculation module uses a pipelined approach to calculate the bandpass filter coefficients. The specific method is as follows: Step S1: Use a multiplier to convert the preset baud rate... Multiply by the number of clocks ; Step S2: Using a multiplier, the result obtained in step S1 is multiplied by the reciprocal of the theoretical frequency value of RCH to obtain the frequency offset value of RCH. ; Step S3: Use a multiplier to convert the frequency offset value of RCH obtained in step S2. Multiply by the constant -2.005; Step S4: Using an adder, add the constant 3.005 to the result obtained in step S3, and then set the result... Save to register; Step S5: Use the adder to convert the coefficients stored in the previous register. Plus ; Step S6, use the multiplier to... Multiply by the result obtained in step S5; Step S7, using an adder, to Adding the result from step S6, we obtain the bandpass filter coefficients. , the coefficient Store in register instead .
5. The device for improving fundamental frequency measurement accuracy according to claim 2, characterized in that, The above is based on the number of clocks Calculate the frequency offset of the RCH. When this is the case, the moving average method is used.
6. The device for improving fundamental frequency measurement accuracy according to claim 5, characterized in that, The average frequency offset is obtained using the moving average method. The calculation method is as follows: ; Where N is the length of the sliding window, and L is the coordinate of the current starting position of the sliding window. For the first in the sliding window Individual frequency offset value.
7. The device for improving fundamental frequency measurement accuracy according to claim 1, characterized in that, The value of the coefficient currently stored in the register is mentioned. The method for calculating its first initial value is as follows: The center frequency of the bandpass filter With system frequency Substitute into the bandpass filter coefficient b when there is no frequency offset Formula, to obtain the initial The value of .
8. The device for improving fundamental frequency measurement accuracy according to claim 7, characterized in that, The center frequency of the bandpass filter With system frequency The preset is based on the actual environment of the fundamental wave measurement.
9. A method for improving the accuracy of fundamental frequency measurement, comprising using the apparatus for improving the accuracy of fundamental frequency measurement as described in any one of claims 1-8, characterized in that, Includes the following steps: Step 1: Using the UART module, determine the number of clock cycles required to transmit one symbol using a baud rate adaptive method. Send it to the computing module; Step 2: The calculation module calculates the bandpass filter coefficients in the fundamental frequency metering device. And save the coefficient to a register; Step 3, based on the bandpass filter coefficients The bandpass filter in the fundamental frequency metering device is adjusted, and then measurement is performed; Among them, the bandpass filter coefficients The calculation methods include: ; in, The center frequency of the bandpass filter. For another coefficient, ; When there is a frequency offset in the RCH, the bandpass filter coefficients The calculation method is as follows: ; After simplification and first-order linear fitting, the bandpass filter coefficients were finally obtained. ,as follows: ; in, yes , This indicates the coefficients currently stored in the register. The value, It is expressed as the average frequency offset.