High-resolution wide-range electric energy pulse output method and system

By using the frequency mean algorithm with complementary adjacent frequencies in the power meter, the resolution and design complexity of the existing power meter when outputting high-frequency pulses is solved, and high-resolution power pulses in the range of 0.001Hz-1MHz are achieved. Output, reducing costs and errors.

CN119310340AInactive Publication Date: 2025-01-14STATE GRID SICHUAN ELECTRIC POWER CO MARKETING SERVICE CENT

Patent Information

Application Number
CN202411645339.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-01-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When implementing high-frequency pulse output, existing power meters have resolution problems, high design complexity, high cost and inability to accurately output high-frequency power pulses at MHz level, resulting in increased system error and design difficulty.

Method used

Using a frequency mean algorithm based on adjacent frequencies, by calculating the timer count value and system clock frequency, a high-resolution pulse output with a frequency output range of 0.001Hz-1MHz is realized, which simplifies hardware circuit design and is low-cost.

Benefits of technology

It realizes a wide range and high-resolution electrical energy pulse output, improves the accuracy of pulse frequency, reduces system error and design difficulty, simplifies hardware design, and reduces economic costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119310340A_ABST
    Figure CN119310340A_ABST
Patent Text Reader

Abstract

The invention discloses a high-resolution and wide-range electric energy pulse output method and system, and the method comprises the steps: calculating a timer count value according to an electric energy pulse frequency value needing to be output and a system clock frequency; judging whether the calculated count value of the timer is an integer or not, if so, directly setting the timer according to the count value of the timer, and controlling the output pulse frequency; otherwise, continuing to execute the subsequent steps; whether the frequency output resolution meets the requirement of the frequency resolution or not is judged, if yes, the timer is set directly according to the integer value of the count value of the timer, and the output pulse frequency is controlled; and otherwise, realizing wide-frequency-range and high-resolution pulse frequency output through a frequency mean value algorithm based on adjacent frequency complementation. According to the invention, through closed-loop feedback calculation of the output pulse frequency and adoption of a frequency mean value algorithm based on adjacent frequency complementation, accurate output of high-resolution electric energy pulses in a wide range of 0.001 Hz-1 MHz can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of electric energy meters, and in particular to a high-resolution, wide-range electric energy pulse output method and system. Background Art

[0002] The energy pulse output of the existing energy meter is directly output through the single-chip microcomputer. To achieve high-frequency pulse and low-frequency pulse output, different output terminals are required. The low-frequency pulse is directly output through the timer. The high-frequency pulse is first multiplied by the phase-locked loop to become a high-frequency clock of tens or hundreds of MHz, and then the energy pulse output of different frequencies is realized through the frequency divider. However, the energy pulse output of different frequencies is realized through the frequency divider, but there are the following problems:

[0003] (1) Since the frequency divider can only divide by integers but not decimals, there is a resolution problem with the pulse output and the output clock frequency cannot be continuously adjusted.

[0004] (2) High-frequency pulses and low-frequency pulses need to use different output terminals, and additional frequency multiplier and divider circuits need to be added, which has high design complexity and high cost performance.

[0005] (3) It is impossible to accurately output high-frequency electric energy pulses at the MHz level. During the electric energy pulse test, the number of pulses actually represents the electric energy value. Therefore, if the electric energy pulse output is inaccurate, it will introduce system errors and lead to inaccurate electric energy values. The electric energy test regulations generally require that the error caused by the accuracy of the electric energy pulse be less than one tenth of the equipment accuracy level. At present, the highest accuracy level of electric energy equipment is 0.01. Therefore, the current direct output of the single-chip microcomputer, taking the single-chip microcomputer clock of 100MHz as an example, can only achieve an accuracy of about 10KHz electric energy pulses of about one ten-thousandth, that is, its resolution is at least an integer of 1 pulse. If the requirement of one hundred thousandth is followed, to achieve accurate output of 1MHz electric energy pulses, a clock frequency of 100GHz is required. At such a high frequency, the distributed capacitance and inductance parameters are greatly affected, and the requirements for circuit design and system design are very high. It is very easy to be interfered with, resulting in clock jitter, increasing system errors, and also increasing the difficulty of system design. In principle, it is possible to achieve high accuracy at a frequency of 1MHz, but there are many problems in practice, high economic costs, and great difficulty in implementation. Summary of the invention

[0006] In order to solve the problems of the current implementation scheme being complex and costly, requiring the addition of additional circuits, being unable to realize fractional frequency division, having low pulse frequency output resolution, and being difficult to realize wide-range, high-resolution electric energy pulse output, the present application provides a high-resolution, wide-range electric energy pulse output method and system. The present application adopts a frequency output algorithm based on complementary adjacent frequencies, which can realize a frequency output range of 0.001Hz-1MHz, and a frequency output resolution of less than 10^ -9 The output of electric energy pulses of any frequency, high-frequency pulses and low-frequency pulses are integrated, no conversion wiring is required, no complicated hardware circuit design is required, the implementation is simple and the cost is low.

[0007] This application is implemented through the following technical solutions:

[0008] A high-resolution, wide-range electric energy pulse output method, the method comprising:

[0009] Calculate the timer count value according to the electric energy pulse frequency value to be output and the system clock frequency;

[0010] Determine whether the calculated timer count value is an integer, if so, directly set the timer according to the timer count value to control the output pulse frequency; otherwise, continue to execute subsequent steps;

[0011] Determine whether the frequency output resolution meets the frequency resolution requirement. If so, set the timer directly according to the integer value of the timer count value to control the output pulse frequency; otherwise, achieve wide frequency range and high resolution pulse frequency output through a frequency averaging algorithm based on complementary adjacent frequencies.

[0012] In some implementations, the timer count value is equal to the ratio of the system clock frequency to the power pulse frequency value required to be output;

[0013] The electric energy pulse frequency value required to be output is calculated based on the current output power and the pulse constant value.

[0014] In some implementations, if the output frequency value corresponding to the frequency resolution requirement is greater than or equal to the power pulse frequency value to be output, then the frequency output resolution meets the requirement, otherwise the frequency output resolution does not meet the requirement;

[0015] The output frequency value corresponding to the frequency resolution requirement is the product of the system clock frequency and the frequency resolution requirement.

[0016] In some implementations, the frequency mean algorithm based on adjacent frequency complementarity specifically includes:

[0017] Set the initial cumulative error value to 0;

[0018] When the cumulative error value is less than 1, the timer count value is set to the integer of the calculated timer count value. If there is a deviation between the actual output pulse frequency value and the set electric energy pulse frequency value, the corresponding count deviation value is the difference between the timer setting value and the timer count value. This deviation value is a fixed deviation value for each pulse, and it constitutes a cumulative error value as the number of pulses accumulates.

[0019] When the accumulated error value exceeds one pulse, the timer count value is set to the calculated timer count value rounded up + 1. At this time, the timer count value counts one more pulse, and the compensation count value is the accumulated error value of the pulse output caused by the rounding of the calculated timer count value.

[0020] In some embodiments, when N pulses are output, the average frequency of the pulse output is:

[0021] N*FCLK / T≈(N-1)*FCLK / TN+FCLK / (TN+1);

[0022] The resolution for N pulses is:

[0023] Re=f / (N*FCLK)

[0024] Among them, FCLK is the system clock frequency, TN is the calculated timer count value rounded, and f is the electric energy pulse frequency value that needs to be output.

[0025] In a second aspect, the present application proposes a high-resolution, wide-range electric energy pulse output system, the system comprising:

[0026] A calculation module, wherein the calculation module calculates a timer count value according to the electric energy pulse frequency value to be output and the system clock frequency;

[0027] A first determination module, wherein the first determination module determines whether the calculated timer count value is an integer, and if so, directly sets the timer according to the calculated timer count value to control the output pulse frequency, otherwise, drives the second determination module to work;

[0028] A second determination module, wherein the second determination module determines whether the frequency output resolution meets the frequency resolution requirement, and if so, directly sets the timer according to the calculated integer value of the timer count value to control the output pulse frequency, otherwise, drives the compensation module to achieve a wide frequency range and high resolution pulse frequency output;

[0029] And, a compensation module, which adopts the above-mentioned frequency averaging algorithm based on complementary adjacent frequencies to achieve high-resolution and accurate output of pulses in a wide frequency range.

[0030] In some implementations, the frequency mean algorithm based on adjacent frequency complementarity specifically includes:

[0031] Set the initial cumulative error value to 0;

[0032] When the cumulative error value is less than 1, the timer count value is set to the integer of the calculated timer count value. If there is a deviation between the actual output pulse frequency value and the set electric energy pulse frequency value, the corresponding count deviation value is the difference between the timer setting value and the timer count value. This deviation value is a fixed deviation value for each pulse, and it constitutes a cumulative error value as the number of pulses accumulates.

[0033] When the accumulated error value exceeds one pulse, the timer count value is set to the calculated timer count value rounded up + 1. At this time, the timer count value counts one more pulse, and the compensation count value is the accumulated error value of the pulse output caused by the rounding of the calculated timer count value.

[0034] In some embodiments, when N pulses are output, the average frequency of the pulse output is:

[0035] N*FCLK / T≈(N-1)*FCLK / TN+FCLK / (TN+1);

[0036] The resolution for N pulses is:

[0037] Re=f / (N*FCLK)

[0038] Among them, FCLK is the system clock frequency, TN is the calculated timer count value rounded, and f is the electric energy pulse frequency value that needs to be output.

[0039] In a third aspect, the present application proposes a single-chip microcomputer hardware system, the single-chip microcomputer hardware system comprising: a single-chip microcomputer and a digital isolator;

[0040] Wherein, the single chip microcomputer is used to implement the steps of the method according to any one of claims 1 to 5, and realize high-resolution and wide-range electric energy pulse output;

[0041] The digital isolator isolates and outputs the electric energy pulse output by the single chip microcomputer.

[0042] In some embodiments, the single-chip computer hardware system further includes a power supply, a reset circuit, a clock crystal oscillator circuit, a data storage device, a communication interface, a display screen, and a watchdog;

[0043] Wherein, the power supply is used to power the single-chip microcomputer and the digital isolator;

[0044] The reset circuit is used to control the single chip microcomputer to perform system reset;

[0045] The clock crystal oscillator circuit provides a system clock for the single-chip microcomputer. The single-chip microcomputer works under the drive of the system clock and is the source of the pulse frequency output clock.

[0046] The data storage device is used to access data;

[0047] The communication interface is used to realize the communication between the single chip microcomputer and the outside;

[0048] The display screen is used to display the setting parameters of the single chip microcomputer;

[0049] The watchdog is used to monitor the operating status of the single chip microcomputer.

[0050] The present application proposes a high-resolution, wide-range electric energy pulse output method and system, which can realize accurate output of high-resolution electric energy pulses with a wide range of frequencies from 0.001Hz to 1MHz by closed-loop feedback calculation of the output pulse frequency and adopting a frequency mean algorithm based on complementary adjacent frequencies. The method and system have the advantages of low software algorithm complexity, can be run on an ordinary single-chip microcomputer, integrated output of low-frequency and high-frequency pulses, no need for conversion wiring for detection, no need for cumbersome hardware circuit design, simple implementation, low cost, and high economic benefits.

[0051] The present application proposes a high-resolution, wide-range electric energy pulse output method and system, which adopts a frequency averaging algorithm based on the complementarity of adjacent frequencies. According to the characteristic of high-frequency electric energy pulses that a large number of pulses are detected within the same detection time, a closed-loop feedback and calculation adjustment method are adopted to achieve an average pulse frequency that is infinitely close to the output pulse frequency, which can increase the resolution by N times (N is the number of detected pulses). Theoretically, electric energy pulse output with any resolution can be achieved. The algorithm process has low calculation amount and can be implemented by ordinary single-chip microcomputers. The present algorithm can achieve high-resolution, wide-range electric energy pulse output under different single-chip microcomputers and different CPU main clock frequencies. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The drawings described herein are used to provide a further understanding of the embodiments of the present application, constitute a part of the present application, and do not constitute a limitation on the embodiments of the present application. In the drawings:

[0053] Figure 1 This is the existing electric energy pulse output principle block diagram;

[0054] Figure 2 It is the principle block diagram of low-frequency pulse and high-frequency pulse output of the existing single-chip microcomputer;

[0055] Figure 3 A flow chart of the electric energy pulse output method proposed in the embodiment of the present application;

[0056] Figure 4 This is a timing diagram of the electric energy pulse output of an embodiment of the present application;

[0057] Figure 5 The figure is a comparison of the resolutions of the frequency averaging algorithm based on complementary adjacent frequencies and the frequency averaging algorithm not based on complementary adjacent frequencies;

[0058] Figure 6 This is a principle block diagram of the electric energy pulse output system proposed in the embodiment of the present application;

[0059] Figure 7 This is a principle block diagram of the single-chip microcomputer hardware system proposed in the embodiment of the present application. DETAILED DESCRIPTION

[0060] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with examples and drawings. The illustrative implementation scheme of the present application and its description are only used to explain the present application and are not intended to limit the present application.

[0061] Example:

[0062] The existing electric energy meter detection is mainly low-frequency pulse method, there is a large difference in the detection time between the high-end detection point and the low-end detection point. The high-end detection point is fast, generally a few seconds, and the low-end detection time is long, the lowest point detection time exceeds 5 minutes. The length of the low-end detection point seriously affects the verification efficiency of the electric energy meter. The pulse output scheme of the existing electric energy meter is as follows Figure 1 As shown, the timer in the microcontroller controls the IO pin to output low-frequency energy pulses. Due to the limitation of the number of bits in the timer, it is impossible to output 0.001Hz pulses. Due to the system clock frequency and the fact that the timer can only divide the frequency by integers, it is impossible to accurately output energy pulses above 1KHz. The energy pulse output isolation adopts a passive optocoupler output solution. Due to the limitation of the bandwidth of the optocoupler, the high-frequency energy pulses will be deformed or even attenuated and filtered out, and cannot pass through, making it difficult to output energy pulses above KHz.

[0063] If you want to realize the low-frequency pulse and high-frequency pulse output transformation plan of the single-chip microcomputer, as shown in Figure 2; first, it cannot be realized on the original circuit, and it is necessary to change the hardware circuit, add multiplier and divider chips and peripheral circuits to realize low-frequency pulse and high-frequency pulse output, and the low-frequency pulse and high-frequency pulse are output at different IO interfaces. Different output interfaces need to be selected according to different electric energy pulse outputs. The wiring operation is complicated and prone to misoperation; secondly, the output of electric energy pulses of different frequencies is realized through the divider, and there are the following problems:

[0064] (1) Since the frequency divider can only divide by integers but not by decimals, when outputting in a wide frequency range, there are problems with the resolution of the pulse output, the output clock frequency cannot be continuously adjusted, and the high-frequency accuracy is not high.

[0065] (2) High-frequency pulses and low-frequency pulses require different output terminals, and additional frequency multiplier and divider circuits need to be added, which increases the design complexity and cost.

[0066] (3) It is impossible to accurately output high-frequency electric energy pulses at the MHz level. During the electric energy pulse test, the number of pulses actually represents the electric energy value. Therefore, if the electric energy pulse output is inaccurate, it will introduce system errors and lead to inaccurate electric energy values. The electric energy test regulations generally require that the error caused by the accuracy of the electric energy pulse be less than one tenth of the equipment accuracy level. At present, the highest accuracy level of electric energy equipment is 0.01. Therefore, the current direct output of the single-chip microcomputer, taking the single-chip microcomputer clock of 100MHz as an example, can only achieve an accuracy of about 10KHz electric energy pulses of about one ten-thousandth, that is, its resolution is at least an integer of 1 pulse. If the requirement of one hundred thousandth is followed, to achieve accurate output of 1MHz electric energy pulses, a clock frequency of 100GHz is required. Such a high frequency has a great influence on the distribution and parasitic capacitance and inductance parameters, and has very high requirements for circuit design and system design. It is very easy to be interfered with, resulting in clock jitter, increasing system errors, and also increasing the difficulty of system design. In principle, it is possible to achieve high accuracy of 1MHz frequency, but there are many problems in practice, high economic cost, and great difficulty in implementation.

[0067] In order to solve the above problems, this embodiment proposes a high-resolution, wide-range electric energy pulse output method, such as Figure 3 As shown, the method specifically comprises the following steps:

[0068] Step 100, obtaining the power pulse frequency value and system clock frequency required to be output.

[0069] From the definition of electric energy pulse constant, we can know that the pulse constant C means that C pulses represent one kilowatt-hour of electric energy. Therefore, the electric energy value represented by each pulse is 1 / C kilowatt-hour. The electric energy value W = P*t. The pulse frequency represents the number of pulses output in 1S, f = W (1 second) / (1 / C kilowatt-hour) = P kilowatts*C. Therefore, the pulse frequency value can be calculated based on the current output power and the pulse constant value.

[0070] Get the system clock frequency FCLK as the clock source for the prescaler and timer of subsequent processing. The system clock frequency is determined during the hardware design. At the same time, the system clock frequency can be calibrated and corrected through external standard equipment, ultimately achieving high-precision electric energy pulse output.

[0071] Step 200, calculating the timer count value according to the power pulse frequency value and the system clock frequency, which is used to divide the output power pulse frequency.

[0072] The calculation formula of the timer count value T is:

[0073] T=FCLK / f

[0074] For example, the timer count value T is composed of a 16-bit prescaler value and a 64-bit general timer count value. If FCLK = 300MHz, the minimum output frequency can reach 300M / (2^ 16 *2^ 64 )≈2.5*10^ -16 Hz, which meets the 0.001Hz output requirement of this embodiment. The frequency resolution formula is:

[0075] Re=f / FCLK

[0076] From the formula of frequency resolution, it can be seen that when FCLK is constant, the frequency resolution is linearly related to the output value. As the output frequency increases, the frequency resolution decreases. According to the above formula, the output f range of this embodiment is 0.001Hz-1MHz, and the corresponding output frequency resolution range is 3.33*10^ -12 -3.33*10^ -3 Therefore, when the output frequency exceeds a certain value, the output frequency resolution is difficult to meet the requirements of this embodiment, and it is necessary to compensate and adjust it according to the output frequency.

[0077] Step 300, determine whether the calculated timer count value is an integer, if it is, directly set the timer according to the calculated timer count value to control the output pulse frequency; otherwise, continue to execute subsequent steps.

[0078] If the timer count value is an integer, the output frequency can be directly obtained by frequency division, and theoretically there is no additional error. Therefore, when the timer count value is an integer, the timer count value TN is directly set to the calculated timer count value T to output an accurate frequency.

[0079] Step 400, determine whether the frequency output resolution meets the frequency resolution requirement. If so, set the timer directly according to the calculated timer count value to control the output pulse frequency; otherwise, a wide frequency range and high resolution pulse frequency output is achieved through a frequency averaging algorithm based on complementary adjacent frequencies.

[0080] If the timer count value is not an integer, different processing is required depending on whether the resolution meets the design requirements. If the frequency output resolution meets the requirements, that is, the output frequency value corresponding to the frequency resolution requirement is greater than or equal to the electric energy pulse frequency value to be output, then the timer count value is directly set according to the integer value of the calculated timer count value to output an accurate pulse frequency.

[0081] If the frequency output resolution does not meet the requirements, that is, the output frequency value corresponding to the frequency resolution requirement is less than the required output electric energy pulse frequency value, a wide frequency range and high resolution pulse frequency output is achieved through a frequency averaging algorithm based on the complementarity of adjacent frequencies.

[0082] Take the integer value of the calculated timer count value, and set the initial output cumulative error value Err to 0; from the principle of the single-chip counter, it can be known that the counter can only be set to an integer value, and cannot be set to a decimal value. When the calculated timer count value is a decimal, at high frequencies, the counter setting value, whether rounded down (TN) or rounded up (TN+1), will cause a large deviation in the frequency, which is manifested as insufficient frequency resolution. There is a problem that the frequency resolution decreases linearly with the output frequency. Therefore, the output resolution cannot be directly achieved by setting the count value. This embodiment proposes a frequency averaging algorithm based on complementary adjacent frequencies. According to the characteristic that the timer can only count integers, for the setting of fractional timer count values, the frequency averaging algorithm based on complementary adjacent frequencies is used to output the fractional pulse frequency output by using the fractional upper and lower integer frequencies for complementary output, thereby achieving high-resolution and accurate output of the pulse wide frequency range.

[0083] Furthermore, the frequency mean algorithm based on adjacent frequency complementarity specifically includes:

[0084] When the cumulative error value is less than 1, the timer count value is set to the integer of the calculated timer count value (that is, TN=T), and the actual output frequency value is f=FCLK / T, and the output pulse frequency is FCLK / TN. Since TN is the integer value of T, T>TN. At this time, there is a deviation between the output frequency pulse and the actual set electric energy pulse frequency value. The frequency deviation value is: FCLK / TN-FCLK / T, and the corresponding count deviation value is T-TN. This deviation value is a fixed deviation value for each pulse and is accumulated with the output pulse value. When N pulses are output, the cumulative count deviation value is: Err=N*(T-TN).

[0085] When the pulse count cumulative deviation exceeds one pulse, that is, Err≥1, the timer count value is set to TN+1. At this time, the count value will count one more pulse to compensate for the pulse output cumulative deviation caused by the count value TN (that is, the cumulative error value minus 1). Therefore, based on N output pulses, the average frequency of the pulse output is:

[0086] N*FCLK / T≈(N-1)*FCLK / TN+FCLK / (TN+1)

[0087] It can be seen from the above formula that when this algorithm is used to output N pulses, the frequency difference of FCLK / T does not exceed 1 pulse count value, that is, compared with the required output electric energy pulse frequency value f=FCLK / T, the resolution of the actual pulse frequency output value is 1 / N, that is, the frequency mean value algorithm based on the complementary adjacent frequencies is used to increase the resolution by N times compared with the direct design of numerical output. Combined with the formula of frequency resolution, the resolution under N pulses is obtained as follows:

[0088] Re=f / (N*FCLK)

[0089] The timing diagram of electric energy pulse output based on the frequency averaging algorithm of adjacent frequency complementation is as follows: Figure 4 shown.

[0090] From the above formula, we can know that when the output frequency and system clock frequency are constant, the accuracy of the average pulse output frequency can be improved by increasing the number of calculated pulses. In theory, the more average calculated pulses are, the higher the resolution of the pulse frequency output is. This can solve the problem of pulse frequency output resolution when the system clock frequency is not high and the output pulse frequency is high, especially for high-frequency pulse output. For example, for a 1MHz high-frequency pulse output, the number of output pulses in 1 second is N=1M, which can achieve an increased resolution of N=10^10 in 1 second. 6 times, the number of output pulses in 10 seconds N = 10M, and the resolution is increased in 10 seconds N = 10^ 7 At present, according to relevant standards and specifications, the energy error calculation time is the reciprocal of the accuracy level and is no less than 5 seconds. For example, for the current highest accuracy level of 0.01, the number of error calculation pulses must be greater than 10,000. For a 1MHz pulse frequency output, the error calculation time is no less than 5 seconds, and the corresponding number of pulses is 5M, and the resolution can be improved by 5*10^ 6 Times. This embodiment divides the time into segments and takes the average frequency of a time period as the output frequency of the set pulse. The pulse output by this method has high accuracy, mainly because the length of the time period, that is, the number of pulses used for electric energy error calculation, and the main clock frequency, that is, the clock frequency of a single counting pulse, can be increased by lengthening the length of the time period or increasing the main clock frequency to solve the problem that the frequency divider can only divide by integers but not by decimals, and high-frequency pulses and low-frequency pulses need to use different output terminals, which can increase the accuracy of the output pulses and theoretically achieve the accurate output of wide-frequency range electric pulses with arbitrary resolution; and, by increasing the number of pulse frequency outputs without changing the original device hardware, the accurate output of wide-frequency range electric pulses with arbitrary resolution can be theoretically achieved.

[0091] This embodiment takes the system clock frequency FCLK=300MHz as an example to verify the above method. Without using the frequency averaging algorithm based on complementary adjacent frequencies, if the range of the required output power pulse frequency value f is 0.001Hz-1MHz, the corresponding output frequency resolution range is 3.33*10^ -12 -3.33*10^-3, when the frequency mean value algorithm based on complementary adjacent frequencies proposed in this embodiment is adopted, the electric energy error calculation time is required to be the accuracy level and not less than 5 seconds according to the regulations. For the accuracy level of 0.01, when the output pulse frequency is 2KHz, that is, the accuracy level requirement is not less than 10,000 pulses, the electric energy error calculation time of 5 seconds is exactly 10,000 pulses. Therefore, for the electric energy pulse frequency output less than 2KHz, the electric energy pulse number needs to be used as the electric energy error calculation time requirement, that is, the pulse number N=10000. According to the resolution calculation formula under N pulses, the resolution of the corresponding frequency is f*3.33*10^ -13 When the output pulse frequency is 2KHz, the output pulse frequency resolution is 6.66*10^ -10 Therefore, when the output pulse frequency is less than 2KHz, the output pulse frequency resolution is less than 6.66*10^ -10 For the electric energy pulse frequency output greater than 2KHz, 5 seconds is used as the electric energy error calculation requirement. The output pulse frequency is f, that is, the number of pulses N = 5*f. According to the resolution calculation formula under N pulses, the resolution of the corresponding pulse output frequency is 6.66*10^ -10 ; In summary, based on the frequency averaging algorithm of complementary adjacent frequencies, it is possible to achieve a pulse output frequency resolution of less than 6.66*10^-10 in the range of 0.001Hz-1MHz, which far exceeds and meets the design requirements of this embodiment.

[0092] The method proposed in this embodiment can achieve accurate output of high-resolution electric energy pulses in a wide frequency range from 0.001 Hz to 1 MHz through closed-loop feedback calculation and adjustment of the output pulse frequency, combined with a frequency averaging algorithm based on the complementarity of adjacent frequencies.

[0093] Based on the same technical concept as above, this embodiment also proposes a high-resolution, wide-range electric energy pulse output system, such as Figure 6 As shown, the system includes:

[0094] The calculation module calculates the timer count value according to the power pulse frequency value to be output and the system clock frequency, so as to distinguish the output power pulse frequency.

[0095] A first determination module, the first determination module determines whether the calculated timer count value is an integer, if it is, directly sets the timer according to the calculated timer count value to control the output pulse frequency; otherwise, drives the second determination module to work;

[0096] The second determination module determines whether the frequency output resolution meets the frequency resolution requirement. If so, the timer is set directly according to the integer value of the calculated timer count value to control the output pulse frequency. Otherwise, the compensation module is driven to achieve a wide frequency range and high resolution pulse frequency output.

[0097] And, a compensation module, which adopts the above-mentioned frequency averaging algorithm based on complementary adjacent frequencies to achieve high-resolution and accurate output of pulses in a wide frequency range.

[0098] It should be noted that the specific implementation process of each functional module in the above system is as described in the above method steps, and will not be repeated here.

[0099] The frequency averaging algorithm based on complementary adjacent frequencies proposed in this embodiment adopts a closed-loop feedback and calculation adjustment method according to the characteristic of high-frequency electric energy pulses that a large number of pulses are detected within the same detection time, so as to achieve an average pulse frequency infinitely close to the output pulse frequency, and can improve the resolution by N times (N is the number of detected pulses). Theoretically, it can achieve electric energy pulse output with any resolution. The algorithm process has low calculation amount and does not require complicated hardware circuit design. It can be implemented by ordinary single-chip microcomputers. The present algorithm can achieve high-resolution and wide-range electric energy pulse output under different single-chip microcomputers and different CPU main clock frequencies.

[0100] This embodiment is described by taking a single chip microcomputer to implement the above method or system as an example. Figure 7As shown in the figure, the hardware architecture of the single-chip microcomputer includes power supply, reset circuit, clock crystal circuit, data storage, communication interface, and touch screen; the power supply includes 3.3V and 5V power supplies, 3.3V power supply is used to power the single-chip microcomputer system, and 5V power supply is used to power the digital isolator; the reset circuit can control the single-chip microcomputer to reset the system; the clock crystal provides the system clock for the single-chip microcomputer. The single-chip microcomputer works under the drive of the system clock and is the source of the pulse frequency output clock; data storage uses an external flash storage chip to expand the data storage space of the single-chip microcomputer and realize the data access and storage function; the communication interface uses the RS232 serial port to communicate with the outside to realize human-computer interaction; the display screen displays the current The machine sets parameters, including output frequency value and other parameters; the watchdog monitors the running status of the single-chip microcomputer. If there is a fault that cannot be recovered by software, such as running dead, the system can be automatically restarted to ensure the stability and reliability of the system; the single-chip microcomputer realizes the hardware platform for the output algorithm of the electric energy pulse and outputs the electric energy pulse. This embodiment can adopt the domestically produced GigaDevice 32-bit single-chip microcomputer with a processor main frequency of up to 600MHz. The built-in large-capacity storage space can support complex operating systems and has both high-performance and low-latency real-time control. It can provide up to 4 USARTs and 4 UARTs, 4 I2Cs, 6 SPIs, 4 I2Ss, 3 CAN-FDs, 2 Ethernets, and supports USB2.0 For FS and HS communication, it has built-in TFT LCD driver and image processing accelerator IPA (Image Processing Accelerator), supports 2D image overlay, rotation, scaling and multiple color format conversion, and has built-in 2 64-bit, 2 32-bit and 1 24-bit timers, with the highest timer frequency of 300MHz. Combined with the frequency averaging algorithm based on complementary adjacent frequencies, it can achieve high-resolution, screen-wide pulse output; the digital isolator uses ADI's ADUM5401, which has 3 outputs and 1 input, and integrates isolated DCDC power supply with a maximum transmission rate of 90MHz, which can achieve the above-mentioned 0.001Hz-1MHz wide range, high-resolution electric energy pulse isolation output requirements.

[0101] It can be seen from this that the method and system proposed in this embodiment can achieve high-resolution, wide-range electric energy pulse output of the single-chip microcomputer without making any changes to the hardware of the single-chip microcomputer, and meet the requirements of wide-range electric energy pulse frequency output. It has the advantages of simple implementation, small changes, and low cost.

[0102] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0103] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0104] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0105] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0106] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only the specific implementation method of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.

Claims

1. A high-resolution, wide-range electric energy pulse output method, characterized in that: The method comprises: Calculate the timer count value according to the electric energy pulse frequency value to be output and the system clock frequency; Determine whether the calculated timer count value is an integer, if so, directly set the timer according to the timer count value to control the output pulse frequency; otherwise, continue to execute subsequent steps; Determine whether the frequency output resolution meets the frequency resolution requirement. If so, set the timer directly according to the integer value of the timer count value to control the output pulse frequency; otherwise, achieve wide frequency range and high resolution pulse frequency output through a frequency averaging algorithm based on complementary adjacent frequencies.

2. A high-resolution, wide-range electric energy pulse output method according to claim 1, characterized in that: The timer count value is equal to the ratio of the system clock frequency to the power pulse frequency value required to be output; The electric energy pulse frequency value required to be output is calculated based on the current output power and the pulse constant value.

3. A high-resolution, wide-range electric energy pulse output method according to claim 1, characterized in that: If the output frequency value corresponding to the frequency resolution requirement is greater than or equal to the electric energy pulse frequency value to be output, then the frequency output resolution meets the requirement; otherwise, the frequency output resolution does not meet the requirement; The output frequency value corresponding to the frequency resolution requirement is the product of the system clock frequency and the frequency resolution requirement.

4. A high-resolution, wide-range electric energy pulse output method according to any one of claims 1 to 3, characterized in that: The frequency mean algorithm based on complementary adjacent frequencies specifically includes: Set the initial cumulative error value to 0; When the cumulative error value is less than 1, the timer count value is set to the integer of the calculated timer count value. If there is a deviation between the actual output pulse frequency value and the set electric energy pulse frequency value, the corresponding count deviation value is the difference between the timer setting value and the timer count value. This deviation value is a fixed deviation value for each pulse, and it constitutes a cumulative error value as the number of pulses accumulates. When the accumulated error value exceeds one pulse, the timer count value is set to the calculated timer count value rounded up + 1. At this time, the timer count value counts one more pulse, and the compensation count value is the accumulated error value of the pulse output caused by the rounding of the calculated timer count value.

5. A high-resolution, wide-range electric energy pulse output method according to claim 4, characterized in that: When N pulses are output, the average frequency of the pulse output is: N*FCLK / T≈(N-1)*FCLK / TN+FCLK / (TN+1); The resolution for N pulses is: Re=f / (N*FCLK) Among them, FCLK is the system clock frequency, TN is the calculated timer count value rounded, and f is the electric energy pulse frequency value that needs to be output.

6. A high-resolution, wide-range electric energy pulse output system, characterized in that: The system comprises: A calculation module, wherein the calculation module calculates a timer count value according to the electric energy pulse frequency value to be output and the system clock frequency; A first determination module, wherein the first determination module determines whether the calculated timer count value is an integer, and if so, directly sets the timer according to the calculated timer count value to control the output pulse frequency, otherwise, drives the second determination module to work; A second determination module, wherein the second determination module determines whether the frequency output resolution meets the frequency resolution requirement, and if so, directly sets the timer according to the calculated integer value of the timer count value to control the output pulse frequency, otherwise, drives the compensation module to achieve a wide frequency range and high resolution pulse frequency output; And, a compensation module, which adopts the above-mentioned frequency averaging algorithm based on complementary adjacent frequencies to achieve high-resolution and accurate output of pulses in a wide frequency range.

7. A high-resolution, wide-range electric energy pulse output system according to claim 6, characterized in that: The frequency mean algorithm based on complementary adjacent frequencies specifically includes: Set the initial cumulative error value to 0; When the cumulative error value is less than 1, the timer count value is set to the integer of the calculated timer count value. If there is a deviation between the actual output pulse frequency value and the set electric energy pulse frequency value, the corresponding count deviation value is the difference between the timer setting value and the timer count value. This deviation value is a fixed deviation value for each pulse, and it constitutes a cumulative error value as the number of pulses accumulates. When the accumulated error value exceeds one pulse, the timer count value is set to the calculated timer count value rounded up + 1. At this time, the timer count value counts one more pulse, and the compensation count value is the accumulated error value of the pulse output caused by the rounding of the calculated timer count value.

8. A high-resolution, wide-range electric energy pulse output system according to claim 7, characterized in that: When N pulses are output, the average frequency of the pulse output is: N*FCLK / T≈(N-1)*FCLK / TN+FCLK / (TN+1); The resolution for N pulses is: Re=f / (N*FCLK) Among them, FCLK is the system clock frequency, TN is the calculated timer count value rounded, and f is the electric energy pulse frequency value that needs to be output.

9. A single-chip microcomputer hardware system, characterized in that: The single-chip microcomputer hardware system comprises: a single-chip microcomputer and a digital isolator; Wherein, the single chip microcomputer is used to implement the steps of the method according to any one of claims 1 to 5, and realize high-resolution and wide-range electric energy pulse output; The digital isolator isolates and outputs the electric energy pulse output by the single chip microcomputer.

10. The single chip computer hardware system according to claim 9, characterized in that: The single-chip computer hardware system also includes a power supply, a reset circuit, a clock crystal oscillator circuit, a data storage device, a communication interface, a display screen and a watchdog; Wherein, the power supply is used to power the single-chip microcomputer and the digital isolator; The reset circuit is used to control the single chip microcomputer to perform system reset; The clock crystal oscillator circuit provides a system clock for the single-chip microcomputer. The single-chip microcomputer works under the drive of the system clock and is the source of the pulse frequency output clock. The data storage device is used to access data; The communication interface is used to realize the communication between the single chip microcomputer and the outside; The display screen is used to display the setting parameters of the single chip microcomputer; The watchdog is used to monitor the operating status of the single chip microcomputer.

Citation Information

Patent Citations

  • Overflow compensating method and device for correcting MEMS elapsed time clock

    CN104143960A

  • High-frequency resolution pulse digital generation system

    CN108566201A

  • High-precision electric energy meter variable threshold value integral differential pulse generation method

    CN110212892A

  • Watthour meter with automatic output pulse width switching type transmitter

    JP1991223679A

  • Parallel accumulator fractional-n frequency synthesizer

    US5777521A

Cited By

  • Intelligent fusion terminal and input pulse metering and power calculation method thereof

    CN122361892A