CN117706465A - Electric energy error measurement method, chip and standard electric energy meter - Google Patents

Electric energy error measurement method, chip and standard electric energy meter Download PDF

Info

Publication number
CN117706465A
CN117706465A CN202311762284.3A CN202311762284A CN117706465A CN 117706465 A CN117706465 A CN 117706465A CN 202311762284 A CN202311762284 A CN 202311762284A CN 117706465 A CN117706465 A CN 117706465A
Authority
CN
China
Prior art keywords
timer
value
measurement
count value
count
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311762284.3A
Other languages
Chinese (zh)
Inventor
宋超
卢宇
曾春山
李鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Clou Electronics Co Ltd
Shenzhen Clou Precision Instrument Co Ltd
Original Assignee
Shenzhen Clou Electronics Co Ltd
Shenzhen Clou Precision Instrument Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Clou Electronics Co Ltd, Shenzhen Clou Precision Instrument Co Ltd filed Critical Shenzhen Clou Electronics Co Ltd
Priority to CN202311762284.3A priority Critical patent/CN117706465A/en
Publication of CN117706465A publication Critical patent/CN117706465A/en
Pending legal-status Critical Current

Links

Landscapes

  • Measurement Of Current Or Voltage (AREA)

Abstract

The application relates to the technical field of electric energy error measurement and discloses an electric energy error measurement method, a chip and a standard electric energy meter. The method comprises the following steps: acquiring a detected pulse constant, the detected pulse quantity, a standard pulse constant and a measured power value; starting a first timer and a second timer, receiving detected pulses input from the outside through the first timer, and outputting standard pulses through a first channel of the second timer; when the first count value is equal to the measurement start count value, starting a third timer, wherein the clock source of the third timer is standard pulse, capturing a first count register value of the second timer, and obtaining a first period register value of the second timer; when the first count value is equal to the measurement end count value, capturing a second count register value of a second timer, acquiring a second period register value of the second timer, and acquiring a third count register value of a third timer; and sequentially calculating the standard pulse number and the electric energy error according to the obtained data.

Description

Electric energy error measurement method, chip and standard electric energy meter
Technical Field
The application relates to the technical field of electric energy error measurement, in particular to an electric energy error measurement method, a chip and a standard electric energy meter.
Background
When the electric energy error is measured, a standard electric energy meter is generally used, standard electric energy pulses of the standard electric energy meter and detected electric energy pulses of the detected electric energy meter are received at the same time, and then the electric energy error of the detected electric energy meter can be calculated by combining the pulse constant of the standard electric energy meter and the pulse constant of the detected electric energy meter. In order to make the measurement of the electric energy error more accurate, it is necessary to ensure the accuracy of pulse counting and the accuracy of counting synchronization in the measurement process. The conventional technology generally triggers external interrupt of the MCU by using standard pulse and detected pulse, and then accumulates respective pulse count values in corresponding interrupt response functions. However, each time the MCU executes a judgment command in the interrupt function, a certain delay is brought, so that a deviation occurs between the calculated value and the actual value of the power error.
Disclosure of Invention
The technical problem that this embodiment of application mainly solves is that use standard electric energy meter to carry out electric energy error measurement among the conventional art and obtain the measured value and have the deviation with the actual value.
In order to solve the technical problems, a first technical scheme adopted in the embodiment of the application is as follows: provided is a power error measurement method, including: acquiring a detected pulse constant, the detected pulse quantity, a standard pulse constant and a measured power value, and calculating a measured start count value and a measured end count value of a first timer; starting the first timer and the second timer, receiving externally input detected pulses through the first timer, outputting standard pulses through a first channel of the second timer, and comparing the measurement start count value with a first count value of the first timer by a comparator of the first timer, wherein the first count value represents the number of detected pulses received by the first timer; when the first count value is equal to the measurement start count value, starting a third timer, wherein the clock source of the third timer is the standard pulse, capturing a first count register value of the second timer through a second channel of the second timer, and acquiring a first period register value of the second timer, wherein the clock source of the second timer is an internal clock; when the first count value is equal to the measurement ending count value, capturing a second count register value of the second timer through the second channel, acquiring a second period register value of the second timer, and acquiring a third count register value of a third timer; calculating a standard pulse number from the first count register value, the first period register value, the second count register value, the second period register value, and the third count register value; and calculating an electric energy error through the detected pulse constant, the detected pulse number, the standard pulse constant and the standard pulse number.
Optionally, after the step of starting the first timer to receive the detected pulse input from the outside and comparing the measurement start count value with the first count value by the comparator of the first timer, the method further includes: if the measurement ending count value is larger than the maximum count value of the first timer, setting an overflow part of the measurement ending count value as the number of times to be overflowed of the first timer; when the number of detected pulses is larger than the maximum count value of the first timer and the first count value is equal to the measurement starting count value, closing a comparison matching event output function of the first timer; when the third timer overflows, adding 1 to an overflow count value of the third timer; when the first timer overflows, judging whether the number of times to be overflowed of the first timer is larger than 0, and if so, subtracting 1 from the number of times to be overflowed; if the comparison matching event output function of the first timer is closed, judging whether the number of times of overflowing to be performed by the first timer is smaller than or equal to 1 in the subsequent comparison matching interrupt response function of the first timer, and if so, restarting the comparison matching event output function of the comparator.
Optionally, the step of calculating a measurement start count value and a measurement end count value of the first timer includes: calculating the measurement start count value according to formula (1):
wherein P represents the measurement power value, C represents the pulse constant to be detected, t represents the synchronization preparation time before the start of measurement, and N start Representing the measurement start count value, N start Is an integer between overflow values greater than 0 and less than the first timer; calculating the measurement end count value according to formula (2):
N end =N start +N set (2)
wherein N is set Representing the number of the detected pulses, N end Representing the end of measurement count value.
Optionally, the step of calculating the standard pulse number by the first count register value, the first period register value, the second count register value, the second period register value, and the third count register value includes: calculating an integer part value of the standard pulse number according to formula (3):
Cnt StdInt =Ovf T3 *N ovf +Cnt T3 (3)
therein, ovf T3 Indicating the count overflow value of the third timer, N ovf Indicating the overflow times of the third timer, cnt T3 Representing the third count register value, cnt StdInt An integer part value representing the number of standard pulses; calculating a fractional part value of the standard pulse number according to formula (4):
wherein Per 1 Representing the first periodic register value, cap 1 Representing the first count register value, per 2 Representing the second period register value, cap 2 Representing the second count register value, cnt StdDec A fractional part value representing the number of standard pulses; calculating the standard pulse number according to formula (5):
Cnt Std =Cnt StdInt +Cnt StdDec (5)
wherein Cnt is Std Representing the standard pulse number.
Optionally, the step of calculating the power error by the detected pulse constant, the detected pulse number, the standard pulse constant, and the standard pulse number includes: calculating the power error according to equation (6):
wherein E represents the electric energy error, C1 represents the detected pulse constant, C2 represents the standard pulse constant, N represents the detected pulse number, and M represents the received standard pulse number.
Optionally, the number of bits of the first timer is equal to the number of bits of the third timer, and the number of bits of the second timer is greater than or equal to 32.
Optionally, before the step of starting the first timer to receive the detected pulse input from the outside, the method further includes: judging whether the first count value of the first timer is 0, and if not, setting the first count value to be 0.
In order to solve the technical problem, a second technical scheme adopted in the embodiment of the application is as follows: providing an electric energy error measurement chip, which comprises a first timer, a second timer and a third timer; the external clock input port of the first timer is connected with external detected pulses, the count value of the first timer is used for accumulating the number of detected pulses, when the count value of the first timer is equal to the calculated measurement starting count value, the comparison matching interruption of the first timer is triggered to output a measurement starting signal, and when the count value of the first timer is equal to the calculated measurement ending count value, the comparison matching interruption of the first timer is triggered to output a measurement ending signal; the clock source of the second timer is an internal clock, the second timer outputs standard pulse through a first channel after being started, a counting register value of the second timer is captured through a second channel of the second timer, and a first channel period register value of the second timer is obtained; the external clock input port of the third timer receives the standard pulse output by the first channel of the second clock, starts when receiving the measurement starting signal, accumulates the integer part value of the standard pulse in one measurement process, and stops when receiving the measurement ending signal; the electric energy error measuring chip is matched with the first timer, the second timer and the third timer to execute the electric energy error measuring method.
In order to solve the above technical problems, a third technical solution adopted in the embodiments of the present application is: providing a standard electric energy meter comprising the electric energy error measuring chip
In order to solve the above technical problems, a fourth technical solution adopted in the embodiments of the present application is: there is provided a non-volatile computer-readable storage medium storing computer-executable instructions that, when executed by an electronic device, cause the electronic device to perform the power error measurement method as described above.
Different from the related art, the method and the device acquire the pulse constant to be detected, the number of the pulses to be detected, the standard pulse constant and the measured power value; starting a first timer and a second timer, receiving detected pulses input from the outside through the first timer, and outputting standard pulses through a first channel of the second timer; when the first count value is equal to the measurement start count value, starting a third timer, wherein the clock source of the third timer is standard pulse, capturing a first count register value of the second timer, and obtaining a first period register value of the second timer; when the first count value is equal to the measurement end count value, capturing a second count register value of a second timer, acquiring a second period register value of the second timer, and acquiring a third count register value of a third timer; and sequentially calculating the standard pulse number and the electric energy error according to the obtained data. The circuit for measuring the electric energy error is further simplified, less hardware resources are used, cost is saved, starting and ending moments of the electric energy error measurement are defined through the comparison and matching function, the internal event triggering function is used for automatic synchronization, the synchronicity of starting and ending of the detected pulse and the standard pulse is improved, and the measuring accuracy of the electric energy error is further improved.
Drawings
One or more embodiments are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements, and in which the figures of the drawings are not to scale, unless expressly stated otherwise.
FIG. 1 is a flow chart of a method for measuring power error according to an embodiment of the present disclosure;
FIG. 2 is a pulse timing diagram of a detected pulse and a standard pulse for conventional power error measurement according to one embodiment of the present application;
FIG. 3 is a schematic diagram of calculating fractional values of the number of standard pulses in accordance with one embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a power error measurement chip according to an embodiment of the present disclosure;
fig. 5 is a schematic hardware structure of a standard electric energy meter for performing an electric energy error measurement method according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
It should be noted that, if not conflicting, the various features in the embodiments of the present application may be combined with each other, which are all within the protection scope of the present application. In addition, while the division of functional blocks is performed in a device diagram and the logic sequence is shown in a flowchart, in some cases, the steps shown or described may be performed in a different order than the block division in a device diagram or the sequence in a flowchart.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The term "and/or" as used in this specification includes any and all combinations of one or more of the associated listed items.
In the current electric energy error measurement technology, to accurately calculate the electric energy error value, firstly, the detected pulse needs to be accurately counted, and the counting of the standard pulse can be started and stopped in time when the counting is started and ended. Secondly, the standard pulse needs to be precisely counted in the electric energy error measurement process, but in the traditional electric energy error measurement process, the detected pulse and the standard pulse are not completely aligned generally, as shown in fig. 2, fig. 2 is a pulse timing diagram of the detected pulse and the standard pulse in the traditional electric energy error measurement process, fig. 2 is that Start is the electric energy error measurement process, stop is the electric energy error measurement process, it can be known from fig. 2 that the standard pulse number is counted more than a part of the numerical value in advance at the beginning time, meanwhile, the standard pulse number is counted less than a part of the numerical value at the ending time, and the counted more numerical value and the counted less numerical value of the standard pulse number cannot be mutually offset. Therefore, in order to obtain an accurate value of the number of standard pulses, it is necessary to accurately calculate the phase difference of the standard pulses from the detected pulse at the start and end of the power error measurement, which represents the fractional value of the number of standard pulses, in addition to the integer fraction value of the number of standard pulses.
In addition, in the current electric energy error measurement technology, when the detected pulse and the standard pulse are counted, the external interrupt of the MCU is usually triggered, and the respective pulse count values are accumulated in the corresponding interrupt response function, but the MCU is frequently interrupted, so that the real-time performance of the task code of the application layer is affected. Then, the MCU executes the judging command in the interrupt function every time, a certain delay is brought, and errors are brought to the calculated value of the standard pulse number, so that the deviation between the calculated value and the actual value of the electric energy error finally occurs.
The drawbacks of the conventional solutions described above are the results of the applicant's practice and careful study, and therefore, the discovery process of the above problems and the solutions presented hereinafter for the above problems should be all contributions to the present application by the applicant during the disclosure process of the present application.
The drawbacks of the above solutions are all the results of the applicant after practice and careful study, and therefore the discovery process of the above problems and the solutions presented hereinafter for the above problems should be all contributions to the present application by the applicant during the disclosure process of the present application.
Referring to fig. 1, fig. 1 is a flow chart of a power error measurement method according to an embodiment of the present application, which specifically includes:
s10, setting a detected pulse constant, the detected pulse number, a standard pulse constant and a measured power value, and calculating a measured start count value and a measured end count value of the first timer.
The pulse constant is used for representing the number of electric energy pulses which are output outwards by the electric energy meter in the process of accumulating 1 kilowatt-hour electric energy, and the unit is imp/kW.h. The selection of the pulse constant depends on the design and application requirements of the electric energy meter, and under the same power, the larger the pulse constant is, the higher the output electric energy pulse frequency is, and the higher the accuracy of the measured electric energy error is.
The measured power value represents the current power value measured by the electric energy meter to be detected, for example, a power supply with the power value being the measured power value is connected to the electric energy meter to be detected. The measurement time represents a time difference between an end time and a start time of an error measurement process for the pulse to be detected.
As a preferred embodiment, the step of calculating the measurement start count value and the measurement end count value of the first timer includes: first, a measurement start count value is calculated according to formula (1):
wherein P represents a measurement power value, C represents a pulse constant to be detected, t represents a synchronization preparation time before measurement starts, N start Indicating a measurement start count value. Then, a measurement end count value is calculated according to formula (2):
N end =N start +N set (2)
wherein N is set Indicating the number of pulses to be detected, N end Indicating the end of measurement count value.
As an alternative embodiment, the number of bits of the first timer may be 16, and the first timer may count in the range of 1 to 65536, and the measurement start count value N may be set start Is an integer less than 50000, and can be the number N of detected pulses in the counting range of the first timer set The pulse to be detected can be maintained to a stable output state for a certain time before the electric energy error measurement is started by keeping a certain margin.
As another alternative embodiment, if the end-of-measurement count value N obtained by calculation end Exceeding the count range of the first timer, e.g. when the first timer is 16 bits, the end count value N is measured end 70000. At this time, the measurement end count value N end The upper 16 bits of the timer are set as the number of times of overflowing to be detected by the first timer, and the calculated measurement end count value N is used end Update the measurement end count value N by the lower 16 bits of (2) end
S20, starting a first timer and a second timer, receiving an externally input detected pulse through the first timer, outputting a standard pulse through a first channel of the second timer, and comparing a measurement start count value with a first count value of the first timer by a comparator of the first timer. Wherein the first count value represents the number of detected pulses received by the first timer.
As an alternative embodiment, before the step of starting the first timer to receive the detected pulse inputted from the outside, the method further comprises: and judging whether the first count value of the first timer is 0, if not, setting the first count value to be 0, and avoiding interference of the first count value of the first timer on the electric energy error measurement process. And then the detected pulse input from outside is received through the external clock input port of the first timer, the clock source of the first timer is set to be an external input clock (namely, the detected pulse input from outside), and the external input clock can be divided into no frequency and can be set to be added with 1 at the rising edge count value of the detected pulse. Meanwhile, a 1-path comparison matching function in the timer is started, namely, the size of the count value and the number of the received detected pulses is compared through a comparator arranged in the first timer, and special explanation is needed that the comparator is used without configuring a hardware output pin corresponding to the comparison matching function, and only needs to enable the comparison matching interrupt and the count overflow interrupt.
As an alternative embodiment, after the step of starting the first timer to receive the detected pulse inputted from the outside and comparing the measurement start count value with the first count value by the comparator of the first timer, the method further includes: if the measurement ending count value is larger than the maximum count value of the first timer, setting an overflow part of the measurement ending count value as the number of times to be overflowed of the first timer; when the number of the detected pulses is larger than the maximum count value of the first timer and the first count value is equal to the measurement start count value, closing the comparison matching event output function of the first timer; when the third timer overflows, adding 1 to the overflow count value of the third timer; when the first timer overflows, judging whether the number of times of overflowing to be performed by the first timer is larger than 0, and if so, subtracting 1 from the number of times of overflowing to be performed; if the comparison matching event output function of the first timer is closed, judging whether the number of times of overflowing to be performed by the first timer is smaller than or equal to 1 in the subsequent comparison matching interrupt response function of the first timer, and if the number of times of overflowing to be performed by the first timer is smaller than or equal to 1, restarting the comparison matching event output function of the comparator.
When the first timer is started, the electric energy error measurement process is triggered by the comparison matching event output by the comparator, and then the electric energy error measurement process is triggered by the second comparison matching event output by the comparator. However, if the number of times of overflowing to be detected is not 0, the comparison matching event output function of the first timer is triggered before the number of received detected pulses does not reach the set total number of received detected pulses, which results in ending the power error measurement process when the number of received detected pulses is insufficient, so that the comparison matching event output function of the first timer needs to be turned off when the number of times of overflowing to be detected is present in the first timer, and then the comparison matching event output function of the first timer is turned on when the number of times of overflowing to be detected is not present, so that the first timer triggers the power error measurement process to end when the first timer receives enough preset total number of detected pulses.
And S30, when the first count value is equal to the measurement start count value, starting a second timer and a third timer, wherein the first channel of the second timer outputs standard pulses, the clock source of the third timer is the standard pulses, and capturing the first count register value of the second timer through the second channel of the second timer to acquire the first period register value of the second timer, wherein the clock source of the second timer is an internal clock.
Wherein the second timer is used for precisely calculating the fractional value of the standard pulse number through the capturing function of the second channel. In the initialization stage, the clock source of the second timer is configured as an internal high-frequency clock, no frequency division is performed, and the count register value of the second timer is accumulated by 1 on the rising edge of the internal high-frequency clock.
The special explanation is that the input capturing function of the second channel in the second timer does not need to enable capturing interruption, namely interruption delay is not generated, and the accuracy of electric energy error measurement is further improved.
S40, when the first count value is equal to the measurement end count value, capturing a second count register value of the second timer through the second channel, obtaining a second period register value of the second timer, and obtaining a third count register value of the third timer.
The third timer is used for accumulating integer parts of the standard pulse number in one measurement process, the bit number of the third timer can be the same as that of the first timer, and the counting register value of the third timer is accumulated by 1 on the rising edge of the clock frequency.
S50, calculating the standard pulse number through the first counting register value, the first period register value, the second counting register value, the second period register value and the third counting register value.
As an alternative embodiment, step S50 specifically includes: calculating an integer part value of the standard pulse number according to formula (3):
Cnt StdInt =Ovf T3 *N ovf +Cnt T3 (3)
therein, ovf T3 Indicating the count overflow value of the third timer, N ovf Indicating the overflow times of the third timer, cnt T3 Representing the third count register value, cnt StdInt An integer part value representing the number of standard pulses;
calculating a fractional part value of the standard pulse number according to formula (4):
wherein Per 1 Representing the first periodic register value, cap 1 Representing the first count register value, per 2 Representing the second period register value, cap 2 Representing the second count register value, cnt StdDec A fractional part value representing the number of standard pulses;
calculating the standard pulse number according to formula (5):
Cnt Std =Cnt StdInt +Cnt StdDec (5)
wherein Cnt is Std Representing the standard pulse number
S60, calculating the electric energy error through the detected pulse constant, the detected pulse number, the standard pulse constant and the standard pulse number.
As an alternative embodiment, step S60 specifically includes: calculating the power error according to equation (6):
wherein E represents an electric energy error, C1 represents a pulse constant to be detected, C2 represents a standard pulse constant, N represents the number of pulses to be detected, and M represents the number of pulses to be received.
As a preferred embodiment, the number of bits of the first timer is equal to the number of bits of the third timer, and the number of bits of the second timer is greater than or equal to 32.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating calculation of a fractional value of a standard pulse number in power error measurement according to an embodiment of the present application. As can be seen from the content of fig. 3, the start point capturing value and the end point capturing value are count register values of the capturing second timer, and the start point period value and the end point period value are period register values of the capturing second timer.
According to the electric energy error measurement method, the pulse constant to be detected, the number of pulses to be detected, the standard pulse constant, the measurement power value and the measurement time are obtained; starting a first timer to receive an externally input detected pulse; when the first count value is equal to the measurement start count value, starting a second timer and a third timer, wherein a first channel of the second timer outputs standard pulses, a clock source of the third timer is the standard pulses, and capturing a first count register value of the second timer to obtain a first period register value of the second timer; when the first count value is equal to the measurement end count value, capturing a second count register value of a second timer, acquiring a second period register value of the second timer, and acquiring a third count register value of a third timer; and sequentially calculating the standard pulse number and the electric energy error according to the obtained data. The circuit for measuring the electric energy error is further simplified, less hardware resources are used, cost is saved, starting and ending moments of the electric energy error measurement are defined through the comparison and matching function, the internal event triggering function is used for automatic synchronization, the synchronicity of starting and ending of the detected pulse and the standard pulse is improved, and the measuring accuracy of the electric energy error is further improved.
Referring to fig. 4, an embodiment of the present application provides a power error measurement chip 400, including a first timer 410, a second timer 420, and a third timer 430;
the external clock input port of the first timer 410 is connected to an external detected pulse, the count value of the first timer 410 is used for accumulating the number of detected pulses, when the count value of the first timer 410 is equal to the calculated measurement start count value, the comparison matching interrupt of the first timer 410 is triggered to output a measurement start signal, and when the count value of the first timer 410 is equal to the calculated measurement end count value, the comparison matching interrupt of the first timer 410 is triggered to output a measurement end signal;
the clock source of the second timer 420 is an internal clock, the second timer 420 outputs a standard pulse through a first channel after being started, captures a count register value of the second timer 420 through a second channel of the second timer 420, and acquires a first channel period register value of the second timer 420;
the external clock input port of the third timer 430 receives the standard pulse output by the first channel of the second clock 420, starts when receiving the measurement start signal, accumulates the integer part value of the standard pulse in one measurement process, and stops when receiving the measurement end signal;
the power error measurement chip 400 cooperates with each other through the first timer 410, the second timer 420, and the third timer 430 to perform the power error measurement method as described above.
It should be noted that, the above-mentioned electric energy error measurement chip 400 may execute the electric energy error measurement method provided in the embodiments of the present application, and has the corresponding functional elements and beneficial effects of the execution method. Technical details not described in detail in the embodiments of the power error measurement chip may be referred to the power error measurement method provided in the embodiments of the present application.
Referring to fig. 5, fig. 5 is a schematic hardware structure diagram of a standard electric energy meter 500 for performing an electric energy error measurement method according to an embodiment of the present application, where the standard electric energy meter 500 includes the electric energy error measurement chip 400, and further includes:
one or more processors 510 and a memory 520, one processor 510 being illustrated in fig. 5.
The processor 510 and the memory 520 may be connected by a bus or otherwise, for example in fig. 5.
The memory 520 is a non-volatile computer readable storage medium, and may be used to store a non-volatile software program, a non-volatile computer executable program, and modules, such as program instructions corresponding to the power error measurement method in the embodiment of the present application. The processor 510 executes various functional applications and data processing of the standard power meter 500 by running non-volatile software programs, instructions and modules stored in the memory 520, i.e., implements the power error measurement method of the method embodiments described above.
Memory 520 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created according to the use of the power error measurement chip 400, etc. In addition, memory 520 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device.
The one or more modules are stored in the memory 520, and when executed by the one or more processors 510, perform the power error measurement method in any of the method embodiments described above, for example, perform the method steps S10 through S60 in fig. 1 described above, implementing the functions of the first, second, and third timers in fig. 4.
The product can execute the method provided by the embodiment of the application, and has the corresponding functional elements and beneficial effects of the execution method. Technical details not described in detail in this embodiment may be found in the methods provided in the embodiments of the present application.
Embodiments of the present application provide a non-volatile computer-readable storage medium storing computer-executable instructions that are executed by one or more processors, such as one processor 510 in fig. 5, to cause the one or more processors to perform the power error measurement method in any of the method embodiments described above, such as performing method steps S10 through S60 in fig. 1 described above, to implement the functions of the first timer, the second timer, and the third timer in fig. 4.
Embodiments of the present application provide a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by the power error measurement chip or the standard power meter, enable the power error measurement chip or the standard power meter to perform the power error measurement method in any of the above-described method embodiments, for example, to perform the method steps S10 to S60 in fig. 1 described above, implementing the functions of the first timer, the second timer, and the third timer in fig. 4.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
From the above description of embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus a general purpose hardware platform, or may be implemented by hardware. Those skilled in the art will appreciate that all or part of the processes implementing the methods of the above embodiments may be implemented by a computer program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and where the program may include processes implementing the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), or the like.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; the technical features of the above embodiments or in the different embodiments may also be combined under the idea of the present application, the steps may be implemented in any order, and there are many other variations of the different aspects of the present application as described above, which are not provided in details for the sake of brevity; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. A method for measuring electrical energy errors, comprising:
acquiring a detected pulse constant, the detected pulse quantity, a standard pulse constant and a measured power value, and calculating a measured start count value and a measured end count value of a first timer;
starting the first timer and the second timer, receiving externally input detected pulses through the first timer, outputting standard pulses through a first channel of the second timer, and comparing the measurement start count value with a first count value of the first timer by a comparator of the first timer, wherein the first count value represents the number of detected pulses received by the first timer;
when the first count value is equal to the measurement start count value, starting a third timer, wherein the clock source of the third timer is the standard pulse, capturing a first count register value of the second timer through a second channel of the second timer, and acquiring a first period register value of the second timer, wherein the clock source of the second timer is an internal clock;
when the first count value is equal to the measurement ending count value, capturing a second count register value of the second timer through the second channel, acquiring a second period register value of the second timer, and acquiring a third count register value of a third timer;
calculating a standard pulse number from the first count register value, the first period register value, the second count register value, the second period register value, and the third count register value;
and calculating an electric energy error through the detected pulse constant, the detected pulse number, the standard pulse constant and the standard pulse number.
2. The power error measurement method according to claim 1, wherein after the step of starting the first timer to receive an externally input pulse to be inspected and comparing the measurement start count value with the first count value by a comparator of the first timer, further comprising:
if the measurement ending count value is larger than the maximum count value of the first timer, setting an overflow part of the measurement ending count value as the number of times to be overflowed of the first timer;
when the number of detected pulses is larger than the maximum count value of the first timer and the first count value is equal to the measurement starting count value, closing a comparison matching event output function of the first timer;
when the third timer overflows, adding 1 to an overflow count value of the third timer;
when the first timer overflows, judging whether the number of times to be overflowed of the first timer is larger than 0, and if so, subtracting 1 from the number of times to be overflowed;
if the comparison matching event output function of the first timer is closed, judging whether the number of times of overflowing to be performed by the first timer is smaller than or equal to 1 in the subsequent comparison matching interrupt response function of the first timer, and if so, restarting the comparison matching event output function of the comparator.
3. The power error measurement method according to claim 1, wherein the step of calculating a measurement start count value and a measurement end count value of the first timer includes:
calculating the measurement start count value according to formula (1):
wherein P represents the measurement power value, C represents the pulse constant to be detected, t represents the synchronization preparation time before the start of measurement, and N start Representing the measurement start count value, N start Is an integer between overflow values greater than 0 and less than the first timer;
calculating the measurement end count value according to formula (2):
N end =N start +N set (2)
wherein N is set Representing the test objectPulse number, N ent Representing the end of measurement count value.
4. The power error measurement method of claim 2, wherein the step of calculating a standard pulse number from the first count register value, the first period register value, the second count register value, the second period register value, and the third count register value comprises:
calculating an integer part value of the standard pulse number according to formula (3):
Cnt StInt =Ovf T3 *N ovf +Cnt T3 (3)
therein, ovf T3 Indicating the count overflow value of the third timer, N ovf Indicating the overflow times of the third timer, cnt T3 Representing the third count register value, cnt StdInt An integer part value representing the number of standard pulses;
calculating a fractional part value of the standard pulse number according to formula (4):
wherein per 1 Representing the first periodic register value, cap 1 Representing the first count register value, per 2 Representing the second period register value, cao 2 Representing the second count register value, cnt StdDec A fractional part value representing the number of standard pulses;
calculating the standard pulse number according to formula (5):
Cnt Std =Cnt StdInt +Cnt StdDec (5)
wherein Cnt is Std Representing the standard pulse number.
5. The power error measurement method according to claim 1, wherein the step of calculating the power error from the detected pulse constant, the detected pulse number, the standard pulse constant, and the standard pulse number includes:
calculating the power error according to equation (6):
wherein E represents the electric energy error, C1 represents the detected pulse constant, C2 represents the standard pulse constant, N represents the detected pulse number, and M represents the received standard pulse number.
6. The power error measurement method of claim 1, wherein the number of bits of the first timer is equal to the number of bits of the third timer, and the number of bits of the second timer is greater than or equal to 32.
7. The power error measurement method of claim 1, wherein prior to the step of starting the first timer to receive an externally input detected pulse, further comprising:
judging whether the first count value of the first timer is 0, and if not, setting the first count value to be 0.
8. The electric energy error measuring chip is characterized by comprising a first timer, a second timer and a third timer;
the external clock input port of the first timer is connected with external detected pulses, the count value of the first timer is used for accumulating the number of detected pulses, when the count value of the first timer is equal to the calculated measurement starting count value, the comparison matching interruption of the first timer is triggered to output a measurement starting signal, and when the count value of the first timer is equal to the calculated measurement ending count value, the comparison matching interruption of the first timer is triggered to output a measurement ending signal;
the clock source of the second timer is an internal clock, the second timer outputs standard pulse through a first channel after being started, a counting register value of the second timer is captured through a second channel of the second timer, and a first channel period register value of the second timer is obtained;
the external clock input port of the third timer receives the standard pulse output by the first channel of the second clock, starts when receiving the measurement starting signal, accumulates the integer part value of the standard pulse in one measurement process, and stops when receiving the measurement ending signal;
the power error measurement chip cooperates with each other through the first timer, the second timer and the third timer to perform the power error measurement method of any one of claims 1-7.
9. A standard electric energy meter comprising the electric energy error measurement chip of claim 8.
10. A non-transitory computer readable storage medium storing computer executable instructions which, when executed by the standard power meter of claim 9, cause the standard power meter to perform the power error measurement method of any one of claims 1-7.
CN202311762284.3A 2023-12-19 2023-12-19 Electric energy error measurement method, chip and standard electric energy meter Pending CN117706465A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311762284.3A CN117706465A (en) 2023-12-19 2023-12-19 Electric energy error measurement method, chip and standard electric energy meter

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311762284.3A CN117706465A (en) 2023-12-19 2023-12-19 Electric energy error measurement method, chip and standard electric energy meter

Publications (1)

Publication Number Publication Date
CN117706465A true CN117706465A (en) 2024-03-15

Family

ID=90160450

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311762284.3A Pending CN117706465A (en) 2023-12-19 2023-12-19 Electric energy error measurement method, chip and standard electric energy meter

Country Status (1)

Country Link
CN (1) CN117706465A (en)

Similar Documents

Publication Publication Date Title
CN109387776B (en) Method of measuring clock jitter, clock jitter measuring circuit, and semiconductor device
TWI586107B (en) Timing Error Detection and Correction Device and Its Normal Timing Design Method
CN110515822B (en) Interrupt response time test method, device, equipment and storage medium
JP2013024853A (en) Frequency counter
TW201303315A (en) Method and system for measuring frequency
CN103197139A (en) Clock frequency test method and clock frequency test circuit
WO2022062671A1 (en) Timing synchronization method, visual navigation aid device control method, and related apparatuses
WO2022062670A1 (en) Timing method, visual navigational aid device control method, and related apparatus
CN112485640B (en) Method, device, equipment and storage medium for detecting built-in capacitor
CN117706465A (en) Electric energy error measurement method, chip and standard electric energy meter
CN117706464A (en) Electric energy error verification method, chip and error plate
CN110047552B (en) Memory reading speed measuring circuit
WO2017173840A1 (en) Method and terminal for determining terminal processor voltage
CN107566199B (en) Signal processing device and method and electronic equipment comprising same
CN116126766A (en) Asynchronous communication data sampling method, device, equipment and medium
CN110687773B (en) Method, device and system for measuring time service precision of time unification system
CN107769933B (en) Automatic testing method and system based on Internet of things timing task
CN111175573A (en) Method, device, equipment and medium for detecting alternating voltage frequency
CN107038109B (en) interrupt delay testing method and device based on MIPS framework
CN117519116B (en) Performance data determining method and device of equipment to be monitored and electronic equipment
CN113030567B (en) Frequency measurement method and device based on single chip microcomputer
WO2017032064A1 (en) Time conversion method, terminal and storage medium
US11695399B2 (en) Digital timer delay line with sub-sample accuracy
CN111884746B (en) Pps second pulse signal output method and system for gptp time synchronization on soc platform
JP4122128B2 (en) Edge detection circuit

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination