Method for managing operation data of electric energy meter
By introducing an intermediate storage area into the power meter, the total electricity data is traced to correct the electricity consumption in the power storage area, solving the problem of data loss when the power meter is updated, and the accuracy of electricity consumption and the reduction of resource consumption is achieved.
Patent Information
- Application Number
- CN202411766107.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-04
AI Technical Summary
In the prior art, when the power meter is updated in the power storage area, data is easily lost due to abnormal state, resulting in inaccurate power consumption of the power meter.
By introducing an intermediate storage area into the power meter, the total power data in the preset format is first stored in the intermediate storage area, and when updating the power consumption in the power storage area, the power consumption is corrected by tracing the data in the intermediate storage area to ensure the accuracy of the accumulated power consumption of the power meter.
It effectively avoids the loss of electricity consumption data due to abnormal states, ensures the accuracy of the accumulated electricity consumption of the electricity meter, and reduces the frequency of resource consumption of the electricity meter controller.
Smart Images

Figure CN119248203B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electric energy meters, and in particular to a method for managing operation data of electric energy meters. Background Art
[0002] In the related art, when the power changes, the increment will be accumulated and calculated to obtain the updated power and the updated power will be stored in the storage area so that the electric energy meter can save the updated power. In order to reduce the impact of data update errors caused by abnormal conditions of the electric energy meter during the update process of the power in the storage area, the power will be divided into two parts, namely the header part and the block part, and the power data of different parts will be stored in the storage area respectively, so that as little data as possible can be changed during the update. For example, if the update only occurs in the block part, the header part does not need to be updated, reducing the impact of data update errors. For example, the header part saves the part before the three decimal places, and the block part only saves the part after the three decimal places of the power. Even if an error occurs in the block part during the storage process, the header part will not be affected, so that the abnormal mutation of the updated power is controlled within a smaller range.
[0003] Although the above-mentioned related technologies control the abnormal mutation of updated power consumption within a smaller range, the data that has already mutated cannot be traced back and corrected, resulting in inaccurate accumulated power consumption of the electricity meter. Summary of the invention
[0004] The purpose of the present invention is to solve at least one of the technical problems existing in the prior art and to provide a method for managing the operation data of an electric energy meter. When an error occurs in the process of updating the electric energy in the electric energy storage area, the electric energy consumption in the electric energy storage area can be corrected by tracing back the total electric energy in a preset format stored in the intermediate storage area to ensure the accuracy of the accumulated electric energy consumption of the electric energy meter.
[0005] In order to achieve the above-mentioned object of the invention, the present invention provides the following technical solutions:
[0006] A method for managing operation data of an electric energy meter, the method comprising:
[0007] The electric energy meter obtains pulse increments according to a preset frequency, and determines whether a preset condition is met based on the obtained pulse increments; wherein the obtained pulse increments are converted into electric increments for accumulation and the accumulated results are stored in an incremental accumulation storage area, and meeting the preset condition means that the accumulated results are not less than a threshold value;
[0008] When the electric energy meter detects that the preset conditions are met, it generates total electric energy data in a preset format based on the accumulation result, and stores the total electric energy data in the preset format in an intermediate storage area; wherein the total electric energy data in the preset format includes a header part and a block part, and the total electric energy data is used to indicate the total electric energy counted by the electric energy meter;
[0009] The electric energy meter updates the electric energy consumption in the electric energy storage area based on the total electric energy data in the intermediate storage area.
[0010] As a further improvement, the corresponding cumulative result when the preset condition is met for the xth time is used as the xth cumulative power consumption increment, where x is a positive integer; the method further includes:
[0011] When it is detected that the preset condition is met for the xth time, the accumulated power consumption increment for the xth time is stored in the temporary storage area;
[0012] The newly acquired pulse increment is accumulated from zero and the accumulated result is stored in the incremental accumulation storage area, so that the accumulated power consumption increment for the x+1th time is obtained when the preset condition is met for the x+1th time.
[0013] As a further improvement, the header part is composed of a header power and a header descriptor corresponding to the header power, and the block part is composed of a block power and a block descriptor corresponding to the block power; when the preset condition is met for the xth time, the total power data in a preset format is generated based on the accumulation result, specifically including:
[0014] Obtain the x-th cumulative power consumption increment from the temporary storage area;
[0015] Get the block power in the block part generated when the preset condition is met for the x-1th time;
[0016] The block power in the block part generated when the preset conditions are met for the x-1th time is added to the cumulative power consumption increment for the xth time to obtain the temporary block power;
[0017] Generate a block descriptor corresponding to the non-carry portion of the temporary block power;
[0018] Generate a block portion based on a non-carry portion of the temporary block power and a block descriptor;
[0019] The temporary block power is added to the head power in the head part generated when the preset condition is met for the x-1th time to obtain the temporary head power;
[0020] Generate a header descriptor corresponding to the temporary header power;
[0021] Generates the header part based on the temporary header power and the header descriptor.
[0022] As a further improvement, the intermediate storage area is composed of adjacent block storage areas and header storage areas, and the total power data in a preset format is stored in the intermediate storage area, specifically including:
[0023] Store the generated block part into the block storage area;
[0024] The generated header part is stored in the header storage area.
[0025] As a further improvement, based on Formula 1 Generate the block descriptor P; wherein, is the i-th digit of the block power in the block part, S is the total number of digits of the block power in the block part, % is the modulus operation, and N is the preset modulus;
[0026] Based on Formula 2 Generate the header descriptor Q; wherein, is the i-th digit of the header power in the header part, T is the total number of digits of the header power in the header part, % is the modulus operation, and N is the preset modulus.
[0027] As a further improvement, the length of each storage area is greater than the length of a data written into the storage area, and the method further includes:
[0028] When writing the first data to the target storage area, write the address str of the first data;
[0029] When writing the y+1th data to the target storage area, if L-(A_(y)%L)≥M, the address of writing the y+1th data is str + (A_(y) % L);
[0030] When writing the y+1th data to the target storage area, if L-(A_(y)%L)<M, the address of writing the y+1th data is str;
[0031] Wherein, y is a positive integer, the target storage area is any storage area among the storage areas, A_(y) is the total length of write statistics obtained after the y-th data is written into the target storage area, L is the length of the target storage area, str is the starting address of the target storage area; and M is the length of the y+1-th data.
[0032] As a further improvement, the total length of write statistics A_(y+1) obtained by counting after the target storage area is written with the y+1th data is determined according to the following steps:
[0033] If (A_(y) % L) + M ≤ L, then A_(y+1) = A_(y) + M;
[0034] If (A_(y) % L) + M > L, then A_(y+1) = A_(y) + M +δ; where δ is the correction increment, δ=L-(A_(y) % L).
[0035] As a further improvement, the method further comprises:
[0036] After the electric energy meter has been running for a preset time, when it detects that the preset conditions are met, it triggers the adjustment of the address ranges of the five storage areas: the incremental accumulation storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area.
[0037] As a further improvement, the address range of the incremental accumulation storage area is str_1 to mtr_1, the address range of the temporary storage area is str_2 to mtr_2, the address range of the block storage area is str_3 to mtr_3, the address range of the header storage area is str_4 to mtr_4, and the address range of the power storage area is str_5 to mtr_5; among which, str_1<str_2<str_3<str_4<str_5, and str_2-mtr_1=str_3-mtr_2=str_4-mtr_3=str_5-mtr_4=1.
[0038] As a further improvement, if the preset condition is met for the x+1th time, the address ranges of the five storage areas of the incremental accumulation storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area are adjusted, then the ratio of the lengths of the storage areas after adjustment is determined based on the following formula 3;
[0039] Formula 3 ;
[0040] The incremental accumulation storage area is named area 1, the temporary storage area is named area 2, the block storage area is named area 3, the header storage area is named area 4, and the power storage area is named area 5; is the length of the adjusted region k, is the regional characteristic parameter of region k, , k∈{k|1,2,3,4,5}, It is the total length of write statistics obtained after the y-th data is written into area k.
[0041] Beneficial effects: 1. Compared with the problem in the prior art that when power data is stored in a power storage area, data is lost due to an abnormal state, resulting in inaccurate accumulated power consumption of the electric energy meter, the present application provides an electric energy meter operation data management method, which first stores the total power data in a preset format for updating power consumption in an intermediate storage area. When an error occurs in the process of updating the power in the power storage area, the power consumption in the power storage area can be corrected by tracing back the total power in the preset format stored in the intermediate storage area, thereby ensuring the accuracy of the accumulated power consumption of the electric energy meter.
[0042] 2. Furthermore, if an error occurs in the process of storing the total electricity data in a preset format into the intermediate storage area, the total electricity in the preset format in the intermediate storage area can also be corrected by tracing back the data stored in the incremental cumulative storage area to ensure the accuracy of the accumulated electricity consumption of the electricity meter.
[0043] 3. At the same time, compared with the prior art, in which once a pulse is detected, the operation of updating the power consumption in the power storage area is triggered, resulting in a problem of high resource consumption of the electric energy meter controller, the frequency of updating the power consumption in the power storage area in the present application can be adjusted based on the threshold, without the need to update when each pulse is measured, thereby reducing the frequency of updating the power consumption and thus reducing the resource consumption of the controller in the electric energy meter.
[0044] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The present invention is further described below in conjunction with the accompanying drawings and embodiments;
[0046] Figure 1 A schematic diagram of data flow during the process of updating power consumption in a power storage area in one embodiment;
[0047] Figure 2 It is a schematic diagram of the status of each storage area after adjusting the address range of each storage area in one embodiment;
[0048] Figure 3 is a schematic diagram of a state after the yth data is written into the target storage area in one embodiment;
[0049] Figure 4 A schematic flow chart of a method for managing operation data of an electric energy meter in one embodiment;
[0050] Figure 5 It is a flowchart of a method for managing operation data of an electric energy meter in another embodiment;
[0051] Figure 6 A schematic diagram of a process for generating total power data in a preset format in one embodiment;
[0052] Figure 7 It is a flowchart of a method for managing operation data of an electric energy meter in another embodiment;
[0053] Figure 8 Schematic diagram of data location in each storage area before and after adjusting the address range in the comparative example. DETAILED DESCRIPTION
[0054] This section will describe in detail the specific embodiments of the present invention. The preferred embodiments of the present invention are shown in the accompanying drawings. The purpose of the accompanying drawings is to supplement the description of the text part of the specification with graphics, so that people can intuitively and vividly understand each technical feature and the overall technical solution of the present invention, but it cannot be understood as a limitation on the scope of protection of the present invention.
[0055] In order to prevent the electric energy meter from suddenly experiencing abnormal conditions, which would lead to the loss of power consumption data, it is necessary to periodically save the power consumption data collected by the electric energy meter into a non-volatile memory (such as EEPROM). In the prior art, the power consumption data is directly saved into a corresponding storage area of the non-volatile memory. However, if an abnormal condition suddenly occurs when the power consumption data is saved in the corresponding storage area of the non-volatile memory, the power consumption data may be lost. In this regard, the present application provides an electric energy meter operation data management method, which can correct the power consumption in the power storage area by tracing back the total power in a preset format stored in an intermediate storage area when an error occurs during the updating of the power in the power storage area, thereby ensuring the accuracy of the accumulated power consumption of the electric energy meter.
[0056] The following will introduce in detail an electric energy meter operation data management method provided by the present application in combination with the accompanying drawings and specific embodiments.
[0057] like Figure 4 As shown, in one embodiment, a method for managing operation data of an electric energy meter is provided, the method comprising:
[0058] In step S202, the electric energy meter obtains pulse increments according to a preset frequency, and determines whether the preset conditions are met based on the obtained pulse increments; wherein the obtained pulse increments are converted into electric increments for accumulation and the accumulated results are stored in an incremental accumulation storage area, and meeting the preset conditions means that the accumulated results are not less than a threshold value.
[0059] Specifically, the energy metering chip used in the energy meter completes the energy metering work and transmits the energy pulse signal to the controller (implemented by a microprocessor). The controller is the core component of the energy meter and is responsible for processing the energy pulse count. For example, if the pulse constant is 6400imp / (kWh), the power increment corresponding to each pulse is 1 / 6400(kWh). If the preset frequency is 6 times per minute, the pulse increment (called pulse increment) within this period is obtained every 10 seconds. For example, after 10 seconds, the pulse increment is 64, and the increment of the applied power (called power increment) is 64 / 6400(kWh), that is, 0.01(kWh). Therefore, in this embodiment, the increment of power consumption can be determined by counting the received pulses. In one example, the threshold is set to 10 / 6400(kWh), that is, the power increment corresponding to when 10 pulses are received. It is understandable that the threshold value can also be set to other values. By adjusting the threshold value, the frequency of updating the power consumption in the power storage area can be controlled, that is, the power consumption in the power storage area is updated once every 10 / 6400 (kWh) is consumed. When the user's power consumption is very small for a period of time, for example, in the early morning, the electrical appliances in the user's home are not used or are only in standby mode, and it may take several hours to consume 10 / 6400 (kWh). At this time, the electric energy meter only needs a few hours to update the power consumption in the power storage area. Compared with the solution in the prior art that updates the power consumption in the power storage area once every pulse is received, the solution of updating the power consumption in the power storage area in this embodiment can save more resource consumption of the electric energy meter controller.
[0060] Step S204, when the electric energy meter detects that the preset conditions are met, it generates total electricity data in a preset format based on the accumulated results, and stores the total electricity data in the preset format into an intermediate storage area; wherein the total electricity data in the preset format includes a header part and a block part, the total electricity data is used to indicate the total electricity counted by the electric energy meter, and the intermediate storage area is composed of adjacent block storage areas and header storage areas.
[0061] Specifically, the corresponding cumulative result when the preset condition is met for the xth time is taken as the xth cumulative power consumption increment, where x is a positive integer; Figure 5 As shown, the method also includes:
[0062] Step S302: When it is detected that the x-th time the preset condition is met, the x-th cumulative power consumption increment is stored in a temporary storage area.
[0063] Step S304, the newly acquired pulse increment is accumulated from zero and the accumulated result is stored in the increment accumulation storage area, so as to obtain the x+1th accumulated power consumption increment when the preset condition is met for the x+1th time.
[0064] In one example, the threshold is set to 10 / 6400, the preset frequency is 6 times per minute, and at 11:36:58 on January 1, 2023, the power consumption in the power storage area is 197.471875. At this time, the pulse increment obtained after 10 seconds is 20 pulses, and the corresponding power increment is 20 / 6400. Assuming that this is the xth time that meets the preset conditions, the xth cumulative power consumption increment is 20 / 6400, and 20 / 6400 is used as the cumulative power consumption increment and stored in the temporary storage area. And then the received pulse increments are accumulated from zero and the accumulated results are stored in the incremental accumulation storage area. For example, in the next 10 seconds, at 11:37:08 on January 1, 2023, the pulse increment obtained is 8, and the corresponding electricity increment is 8 / 6400, that is, the cumulative result is 8 / 6400, and the threshold is set to 10 / 6400. At this time, it does not meet the preset conditions, and accumulation continues. If at 11:37:08 on January 1, 2023, that is, after the 20th second, the pulse increment obtained is 5, 8+5=13, and the corresponding electricity increment is 13 / 6400, that is, the cumulative result is 13 / 6400. At this time, it meets the preset conditions, and the cumulative electricity consumption increment for the x+1th time is 13 / 6400.
[0065] Specifically, the header part is composed of the header power and the header descriptor Q corresponding to the header power, and the block part is composed of the block power and the block descriptor P corresponding to the block power; it can be understood that the technical personnel in this field can adjust the delimiter number according to the needs, for example, the delimiter number is n, n is a natural number, then the header power saves the n-digit decimal (i.e., the nth digit after the decimal point) and the part before, and the block power saves only the part after the n-digit decimal of the power. In an example, the delimiter number is 3, that is, the header power saves the three-digit decimal (i.e., the third digit after the decimal point) and the part before, and the block power saves only the part after the three-digit decimal of the power. For example, if the power consumption is 197.471875, the header power is 197.471 and the block power is 875. If the power consumption is converted into the block part and the header part, the block part is 8750, and the header part is 197.4719, where the last digit of the block part is 0, which is the block descriptor P, and the last digit of the header part is 9, which is the header descriptor Q. The specific generation algorithm of the two descriptors refers to the following formulas 1 and 2.
[0066] like Figure 6 As shown, when the preset condition is met for the xth time, the total power data in a preset format is generated based on the accumulated result, specifically including:
[0067] Step S401, obtaining the x-th cumulative power consumption increment from the temporary storage area, which in this example is 20 / 6400=0.003125.
[0068] Step S402, obtaining the block power in the block part generated when the preset condition is met for the x-1th time from the block storage area, which is 875 in this example.
[0069] Step S403, adding the block power in the block part generated when the preset condition is met for the x-1th time to the xth cumulative power consumption increment to obtain a temporary block power.
[0070] Specifically, when performing the addition calculation, the block power will be converted into a value matching the corresponding unit (i.e., Kwh), that is, the block power will be restored to the position after the three decimal places, and after the conversion, it will be 0.000875, so the temporary block power = 0.000875 + 0.003125 = 0.004. Obviously, a carry has occurred. Among them, a carry has occurred when the temporary block power (i.e., 0.004) obtained is different from the converted value of the block power in the block part generated when the preset conditions are met for the x-1th time (i.e., 0.000875) in the same position before and after the three decimal places. Obviously, the third digit after the decimal point in 0.004 is 4, while the third digit after the decimal point in 0.000875 is 0. If the values in the same position of the two are different, it is considered that a carry has occurred. In general, a carry has occurred when the temporary block power obtained is different from the converted value of the block power in the block part generated when the preset conditions are met for the x-1th time in the same position before and after the decimal place.
[0071] Specifically, the carry part refers to the value located at the decimal point on and before the delimiter in the temporary block power. For example, the temporary block power = 0.000875 + 0.003125 = 0.004000, 0.004000, then 0.004 is the carry part, and 0 is the non-carry part. Specifically, the head power in the head part is obtained from the head storage area. It should be noted that the head power in the head part obtained from the head storage area at this time is the old head power, and the temporary head power obtained after the addition calculation is the new head power. In this example, the old head power is 197.471. Therefore, the temporary head power is calculated to be 197.471 + 0.004 = 197.475.
[0072] Similarly, if no carry occurs, the part with carry is 0. For example, if the cumulative power consumption increment = 0.00125, and the block power is 0, then the sum is equal to 0.00125, then the part with carry is 0, and the part without carry is 0.00125.
[0073] Step S404, generating a block descriptor corresponding to the non-carry portion of the temporary block power.
[0074] Let the temporary block power be the block power in Formula 1 and substitute it into Formula 1 to generate a block descriptor P corresponding to the non-carry part of the temporary block power.
[0075] Step S405: Generate a block part based on the non-carry part of the temporary block power and the block descriptor.
[0076] Step S406: Add the carry portion of the temporary block power to the head power in the head part generated when the preset condition is met for the x-1th time to obtain the temporary head power.
[0077] Step S407: Generate a header descriptor corresponding to the temporary header power level.
[0078] The temporary head power is taken as the head power in Formula 2 and substituted into Formula 2 to generate a head descriptor Q corresponding to the temporary head power.
[0079] Step S408: Generate a header part based on the temporary header power and the header descriptor.
[0080] Step S206: the electric energy meter updates the electric energy consumption in the electric energy storage area based on the total electric energy data in the intermediate storage area.
[0081] Based on the above steps S401 to S408 , it can be known that the block part generated when the condition is met for the xth time has been stored in the block storage area and the header part generated has been stored in the header storage area.
[0082] Therefore, in step S206 , the power consumption in the power storage area may be updated based on the total power data in the intermediate storage area.
[0083] Specifically, the head power of the header part is obtained from the header storage area, and the block power of the block part is obtained from the block storage area. The two are combined to obtain the complete power consumption, and then the power consumption is written into the power storage area to complete the update of the power consumption. In one example, the obtained head power is 198.475 and the block power is 78125, then the combined form is 198.47578125, and then the data in this form is written into the power storage area. Specifically, in some examples, each bit of the total power data in the above preset format occupies one byte and is represented by ASCII code.
[0084] Beneficial effects: 1. Compared with the problem in the prior art that when power data is stored in a power storage area, data is lost due to an abnormal state, resulting in inaccurate accumulated power consumption of the electric energy meter, the present application provides an electric energy meter operation data management method, which first stores the total power data in a preset format for updating power consumption in an intermediate storage area. When an error occurs in the process of updating the power in the power storage area, the power consumption in the power storage area can be corrected by tracing back the total power in the preset format stored in the intermediate storage area, thereby ensuring the accuracy of the accumulated power consumption of the electric energy meter.
[0085] 2. Furthermore, if an error occurs in the process of storing the total electricity data in a preset format into the intermediate storage area, the total electricity in the preset format in the intermediate storage area can also be corrected by tracing back the data stored in the incremental cumulative storage area to ensure the accuracy of the accumulated electricity consumption of the electricity meter.
[0086] 3. At the same time, compared with the prior art, in which once a pulse is detected, the operation of updating the power consumption in the power storage area is triggered, resulting in a problem of high resource consumption of the electric energy meter controller, the frequency of updating the power consumption in the power storage area in the present application can be adjusted based on the threshold, without the need to update when each pulse is measured, thereby reducing the frequency of updating the power consumption and thus reducing the resource consumption of the controller in the electric energy meter.
[0087] Based on Formula 1 Generate the block descriptor P; wherein, is the i-th digit of the block power in the block part, S is the total number of digits of the block power in the block part, % is the modulus operation, and N is the preset modulus;
[0088] Based on Formula 2 Generate the header descriptor Q; wherein, is the i-th digit of the header power in the header part, T is the total number of digits of the header power in the header part, % is the modulus operation, and N is the preset modulus.
[0089] In one example, the preset modulus is 10, the block power is 875, and the head power is 197.471. The total number of digits of the block power is 3, the first digit is 8, the second digit is 7, and the third digit is 5. Substituting into formula 1, the block descriptor P=(8+7+5)%10=0 is obtained. The total number of digits of the head power is 6, the first digit is 1, the second digit is 9, the third digit is 7, the fourth digit is 4, the fifth digit is 7, and the sixth digit is 1. The block descriptor P=0 is substituted into formula 2 to obtain the head descriptor Q=(1+9+7+4+7+1+0)%10=9.
[0090] Since the power consumption is divided into two parts and stored in the header storage area and the block storage area respectively, when the header part and the block part are taken out from the header storage area and the block storage area respectively to update the power consumption in the power storage area, the header power and block power respectively obtained may be wrong due to program abnormalities and other reasons. In this regard, the header power and block power can be verified by the corresponding descriptors when reading out the block part and the header part. Furthermore, since the generation of the header descriptor in Formula 2 depends on the corresponding block descriptor, the block descriptor provided in this embodiment can also be used to verify whether the header power and block power respectively obtained are a pair of matching data. For example, when the preset conditions are met for the xth time, the header part of the total power data in the preset format generated based on the accumulation result is 197.4719, and the block part is 8750, and the two are a pair of matching data. Furthermore, when the power consumption in the power storage area is updated based on the pair of data, two parts of data will be taken out from the header storage area and the block storage area respectively for combination. Due to program abnormality, the header power or block power taken out may not be a pair of data. For example, the header power may be the header power generated when the preset conditions are met for the x-1th time, for example, the header part is 197.4705, and the block part is still 8750. Obviously, when the block part is checked based on formula one, it can pass, but when the header part is checked based on formula two, it will be found that the check cannot pass. At this time, it can be determined that the obtained header part and block part are not a matching pair of data.
[0091] In one embodiment, the intermediate storage area is composed of adjacent block storage areas and header storage areas, and storing the total power data in a preset format into the intermediate storage area specifically includes: storing the generated block part into the block storage area; storing the generated header part into the header storage area.
[0092] Specifically, the length of each storage area is greater than the length of a data written into the storage area, such as Figure 7 As shown, the method also includes:
[0093] Step S501: receiving a command to write a data into a target storage area.
[0094] Step S502, determine whether it is the first data in the target storage area. If yes, jump to step S504; if no, jump to step S503.
[0095] Step S503, determine whether L-(A_(y)%L) is not less than M. If so, jump to step S505; if not, jump to step S506.
[0096] Step S504, determine that the write address of the first data is str and jump to step S507.
[0097] Step S505, determine that the address to be written into the y+1th data is str + (A_(y) % L) and jump to step S507.
[0098] Step S506, determining that the address to be written into the y+1th data is str.
[0099] Step S507, end the process.
[0100] Wherein, y is a positive integer, the target storage area is any one of the five storage areas: incremental accumulation storage area, temporary storage area, block storage area, header storage area, and power storage area; A_(y) is the total length of write statistics obtained after the y-th data is written into the target storage area; L is the length of the target storage area; str is the starting address of the target storage area; and M is the length of the y+1-th data.
[0101] For example, Figure 3 As shown, the target storage area ranges from 0x2100 to 0x210A, that is, the starting address str is 0x2100, and the length L of the target storage area is 19 bytes. When the first data is written to the target storage area, the address str of the first data is 0x2100, and the length of the first data is 3 bytes. When the second data is written to the target storage area, at this time, the total length of the write statistics obtained after the first data is written to the target storage area (A_(1) is 3, if the length M of the second data is 8 bytes, then L-(A_(y)%L)=19-(3%19)=16≥8, then the address of the second data is str + (A_(1) % L)=0x2100+(3%19)=0x2103, that is Figure 3 The position shown in the shaded area. When the third data is written to the target storage area, the total length of the write statistics obtained after the second data is written to the target storage area (A_(2) is 11. If the length of the third data M is 9 bytes, then L-(A_(2)%L)=19-(11%19)=8 < 9, and the address of the third data is str =0x2100.
[0102] By adopting the method provided in this embodiment, it can be ensured that each storage location in the storage area can be written more evenly, thereby achieving a balanced wear effect.
[0103] Specifically, the total length of write statistics A_(y+1) obtained by counting after the target storage area is written with the y+1th data is determined according to the following steps:
[0104] If (A_(y) % L) + M ≤ L, then A_(y+1) = A_(y) + M;
[0105] If (A_(y) % L) + M > L, then A_(y+1) = A_(y) + M +δ; where δ is the correction increment, δ=L-(A_(y) % L).
[0106] For example, Figure 3 As shown in the figure, the target storage area ranges from 0x2100 to 0x210A, that is, the starting address str is 0x2100, and the length L of the target storage area is 19 bytes. When writing the first data to the target storage area, the address str of the first data is 0x2100, and the length of the first data is 3 bytes. It is defined that the total length of the write statistics A_(1) obtained after the first data is written to the target storage area is equal to the length of the first data, that is, A_(1)=3. When writing the second data to the target storage area, if the length M of the second data is 8 bytes, then (A_(1) % 19) + 8=9 ≤ 19, so A_(2)=A_(1) + M=3+8=11. If the length of the third data is 9, then (A_(2) % 19) + 9=20 > L, so A_(3) =A_(2) + M +δ=11+9+19-(A_(2) % 19)=28.
[0107] Furthermore, the method further includes the step of reading the data in each storage area:
[0108] Step S601, a register is set for the target storage area, the register is used to save the starting address of the target storage area, the length of the target storage area, the write address corresponding to the latest data written to the target storage area, and the total length of the write statistics obtained after the latest data is written to the target storage area; wherein the register is a storage area in a non-volatile memory. The starting address of the target storage area is recorded as str, the length of the target storage area is recorded as L, the write address corresponding to the latest data written to the target storage area is recorded as Addr_S, and the total length of the write statistics obtained after the latest data is written to the target storage area is recorded as LEN.
[0109] Step S602, after detecting that a write operation of a data has been completed in the target storage area, the write address corresponding to the write operation and the total length of write statistics obtained after the data is written into the target storage area are updated into the register.
[0110] Step S603, when a read operation request for the target storage area is received, the read operation address is set to Addr_S, and the length of the read data is str+(LEN % L)-Addr_S.
[0111] For example, in one example, Figure 3 As shown, Figure 3 The shadow in the middle is the latest data written. The starting address of the target storage area is 0x2100. An 8-byte data is written at the write address 0x2103. After the data is written, the total length of the write statistics is 30. Therefore, after completing the write operation of the data, the register is updated to Addr_S=0x2103, LEN=30.
[0112] When a read operation request is received for the target storage area, the read operation address is set to Addr_S = 0x2103, and the length to be read is str + (LEN % L) - Addr_S = 0x2100 + (30%19) - 0x2103 = 8 bytes.
[0113] It can be seen that the data reading method of steps S601 to S603 in this embodiment cooperates with the data writing method of steps S501 to S507 to ensure that the data read from the five storage areas of the incremental cumulative storage area, the temporary storage area, the block storage area, the head storage area, and the power storage area are all the latest data saved in the storage area. That is, the embodiment of the present application can provide a method for efficiently writing and reading data in each storage area without writing a piece of data to a fixed storage location, but evenly writing data to multiple storage locations in a storage area to achieve wear leveling. For each storage area, only four parameters in the management register are needed to record the address range of the target storage area, the write operation address, the read operation address, the corresponding data length of the read operation, and the cumulative number of writes in each storage area, without the need to establish a complex mapping table to record the location of each piece of data, saving more storage resources.
[0114] In one embodiment, the method also includes: after the electric energy meter has run for a preset time, when it detects that a preset condition is met, triggering adjustment of the address ranges of five storage areas: the incremental accumulation storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area.
[0115] In order to make the wear of each storage area more balanced, the address range of each storage area should be adjusted according to the characteristics of the write operation of each storage area, so that the number of write operations of each storage area in the same time is similar. Therefore, it is necessary to let the electric energy meter run for a preset time, such as one month, to count the characteristics of the write operation of each storage area in one month, and then adjust the address range of each storage area based on formula three.
[0116] Furthermore, it should be noted that if Figure 1As shown, the incremental accumulation storage area is named as area 1, the temporary storage area is named as area 2, the block storage area is named as area 3, the header storage area is named as area 4, and the power storage area is named as area 5. Then the address range of the incremental accumulation storage area is str_1 to mtr_1, the address range of the temporary storage area is str_2 to mtr_2, the address range of the block storage area is str_3 to mtr_3, the address range of the header storage area is str_4 to mtr_4, and the address range of the power storage area is str_5 to mtr_5; wherein, str_1<str_2<str_3<str_4<str_5, and str_2-mtr_1=str_3-mtr_2=str_4-mtr_3=str_5-mtr_4=1.
[0117] In other words, in the order of address range from small to large, the five storage areas are incremental accumulation storage area, temporary storage area, block storage area, header storage area, and power storage area. Figure 1 As shown, the curve with arrows indicates the data flow, and the arrows point to the direction of data flow. It is known that each time the preset conditions are met, the following operations need to be performed:
[0118] Step S1, accumulating the pulse increment in the incremental accumulation storage area to obtain the x-th cumulative power consumption increment.
[0119] Step S2, storing the x-th cumulative power consumption increment in the incremental cumulative storage area into the temporary storage area.
[0120] Step S3, generating a block part based on the x-th cumulative power consumption increment in the temporary storage area and storing it in the block storage area;
[0121] Step S4, if a carry occurs, generating a header part based on the block part in the block storage area and storing it in the header storage area;
[0122] Step S5: updating the power consumption based on the block part and the header part in the block storage area and the header storage area and storing the updated power consumption in the power storage area.
[0123] In some embodiments, if the preset condition is met for the x+1th time, the address range of the five storage areas of the incremental cumulative storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area is adjusted. Specifically, as described in steps S601 to S603 above, register No. 1 is used to save the starting address str_1 of area 1, the length L_1 of the target storage area, the write address Addr_S_1 corresponding to the latest data written to the target storage area, and the total length LEN_1 of the write statistics obtained after the latest data is written to the target storage area. Similarly, register No. n is used to save the starting address str_n of area n, the length L_n of the target storage area, the write address Addr_S_n corresponding to the latest data written to the target storage area, and the total length LEN_n of the write statistics obtained after the latest data is written to the target storage area. The address range of the five storage areas of the incremental cumulative storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area referred to in this embodiment is actually to adjust the four parameters in the registers corresponding to each storage area.
[0124] The specific adjustment steps are as follows:
[0125] Step A, after the electric energy meter has run for a preset time, when it detects that the preset conditions are met for the x+1th time, it enters the adjustment mode; wherein str_n' is the new starting address of the adjusted area n, L_n' is the new length of the adjusted area n, Addr_S_n' is the write address corresponding to the latest data written to the adjusted area n, and LEN_n is the new total length of the write statistics of the adjusted area n.
[0126] When the adjustment mode is detected, the following steps are performed:
[0127] Step B: when it is detected that the parameters Addr_S_2 and LEN_2 of register No. 2 are adjusted, the parameters str_1 of register No. 1 are set to str_1', the parameter L_1=L_1', the parameter Addr_S_1=str_1', and the parameter LEN_1=0.
[0128] Step C, after executing step B and detecting that the read operation on area 3 is completed, set the parameter str_2 of register No. 2 to str_2', parameter L_2 to L_2', parameter Addr_S_2 to str_2', and parameter LEN_2 to 0; and set the parameter str_3 of register No. 3 to str_3', parameter L_3 to L_3', parameter Addr_S_3 to str_3', and parameter LEN_3 to 0.
[0129] Step D, after executing step C and detecting that the read operation on area 4 is completed, set the parameter str_4 of register 4 to str_4', parameter L_4 to L_4', parameter Addr_S_4 to str_4', and parameter LEN_4 to 0.
[0130] Step E, after executing step D and detecting that the read operations on both area 3 and area 4 are completed, set the parameter str_5 of register 5 to str_5', parameter L_5 to L_5', parameter Addr_S_5 to str_5', and parameter LEN_5 to 0; exit the adjustment mode.
[0131] Through the above steps, the address range of each storage area can be efficiently adjusted without relocating the original data in each storage area. Figure 2 As shown in FIG. 1 , in one embodiment, a schematic diagram of the range of each storage area after adjusting the address range of each storage area. It should be noted that in the process of adjusting the address range of each storage area according to steps A to E, if Figure 1 As shown, in order of address range from small to large, the five storage areas are incremental accumulation storage area, temporary storage area, block storage area, header storage area, and power storage area. By setting each storage area in the above order, it is possible to avoid the problem of old data being overwritten and lost when writing data without relocating the data to adjust the address range of each storage area. Relocating data means copying the original data in a storage area, and after adjusting the address range of the storage area, writing the copied data to the new address of the storage area. This method will increase the storage space overhead and the time cost of data movement.
[0132] like Figure 8 As shown, the following is an example of a comparative example. For the xth time when the preset condition is met, the data in area k will be used to generate the data in area k+1, and after the data in area k is used to generate the data in area k+1, the next data to be written in area k is the data generated when the preset condition is met for the x+1th time. Figure 8 , the five storage areas are area 5, area 3, area 3, area 4, and area 1 in the order of address range from small to large. For example, if the data in area 5 is to be updated based on the data generated in area 4 when the preset condition is met for the xth time, and the address range of area 1 is adjusted when the preset condition is met for the x+1th time, the address range of area 1 is adjusted and the range is expanded, and the first step data written after the range of area 1 is adjusted is located at the minimum position of area 1, which will cause area 1 to overlap with area 4 whose range is not adjusted after adjustment, resulting in the data in area 4 being overwritten and lost. Figure 8The shaded area in the figure represents the position range of the latest data written into each storage area before and after the adjustment.
[0133] In this regard, it is known that in this embodiment, as shown in steps A to E, the order in which the addresses of the storage areas are adjusted is also consistent with the order in which the data are generated in the storage areas, that is, Figure 1 As shown, therefore, in this embodiment, the storage area that generates data first when the preset condition is met for the xth time is arranged at the position with the smallest address range, and the storage area with the latest adjusted address range is also arranged at the position with the smallest address range. Therefore, when the preset condition is met for the x+1th time, the address range of the storage area that needs to write data first is smaller than the storage area that needs to write data later. After the address range is adjusted, each storage area writes data from the smallest position. Therefore, the newly written data after the address range of each storage area is adjusted will not overlap with the position of the data in the storage area with a smaller address range, thereby avoiding the problem of data coverage after the address range of different storage areas is adjusted.
[0134] In one embodiment, if the preset condition is met for the x+1th time, the address ranges of the five storage areas of the incremental accumulation storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area are adjusted, and the ratio of the lengths of the storage areas after adjustment is determined based on the following formula 3;
[0135] Formula 3 ;
[0136] The incremental accumulation storage area is named area 1, the temporary storage area is named area 2, the block storage area is named area 3, the header storage area is named area 4, and the power storage area is named area 5; is the length of the adjusted region k, is the regional characteristic parameter of region k, , k∈{k|1,2,3,4,5}, It is the total length of write statistics obtained after the y-th data is written into area k.
[0137] Formula 3 is the regional characteristic parameter of region k, which reflects the writing frequency characteristic of a certain storage region. That is, if the parameter is large, the writing frequency is high, and if the parameter is small, the writing frequency is low. In order to make each storage region wear evenly, it is necessary to adjust the writing frequency of each storage region to be as close as possible. And because different electric energy meters have different power consumption conditions, the default values of each storage region of different electric energy meters are no longer applicable. Therefore, Formula 3 is used to adjust the length of each storage region to achieve the effect of wear balancing.
[0138] In the above steps A to E, str_n' is the new starting address of area n after adjustment, and L_n' is the new length of area n after adjustment. According to Formula 3, for example, if L_1': L_2': L_3': L_4': L_5'=6:4:2:2:2, and the total length of area 1 to area 5 is 1024 bytes, and the starting address of area 1 before adjustment is 0x1000, then L_1'=1024*(6 / (6+4+2+2+2))=384 bytes, L_2'=256 bytes, L_3'=128 bytes, L_4'=128 bytes, and L_5'=128 bytes. Correspondingly, after adjustment of area 1, str_1'=0x1000, str_2'=str_1'+L_1', str_3'=str_2'+L_2', str_4'=str_3'+L_3', str_5'=str_4'+L_4', that is, str_(n+1)'=str_n'+L_n'. It can be understood that if there is a decimal point when calculating L_n', it is rounded off, for example, L_1'=1024*(1 / (5+2+1+1+1))=102.4, then L_1'=102 bytes.
[0139] In one embodiment, an electric energy meter operation data management device is also provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps of the electric energy meter operation data management method when executing the program. The steps of the electric energy meter operation data management method here may be the steps in the above-mentioned embodiments.
[0140] In one embodiment, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores computer-executable instructions, wherein the computer-executable instructions are used to enable a computer to execute the steps of the above-mentioned method for managing the operation data of an electric energy meter. The steps of the method for managing the operation data of an electric energy meter here may be the steps of the method for managing the operation data of an electric energy meter in the above-mentioned embodiments.
[0141] In one embodiment, an electric energy meter is further provided. The electric energy meter includes a controller and an electric energy metering chip. The controller is used to execute the above-mentioned electric energy meter operation data management method.
[0142] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRA), memory bus (Rambus) direct RAM (RDRA), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0143] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A method for managing operation data of an electric energy meter, characterized in that: The method comprises: The electric energy meter obtains pulse increments according to a preset frequency, and determines whether a preset condition is met based on the obtained pulse increments; wherein the obtained pulse increments are converted into electric increments for accumulation and the accumulated results are stored in an increment accumulation storage area, and meeting the preset condition means that the accumulated result is not less than a threshold value; When the electric energy meter detects that the preset conditions are met, it generates total electric energy data in a preset format based on the accumulation result, and stores the total electric energy data in the preset format in an intermediate storage area; wherein the total electric energy data in the preset format includes a header part and a block part, and the total electric energy data is used to indicate the total electric energy counted by the electric energy meter; The electric energy meter updates the electric energy consumption in the electric energy storage area based on the total electric energy data in the intermediate storage area; The method further comprises: After the electric energy meter runs for a preset time, when it detects that the preset conditions are met, it triggers the adjustment of the address ranges of the five storage areas: the incremental accumulation storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area; The address range of the incremental accumulation storage area is str_1 to mtr_1, the address range of the temporary storage area is str_2 to mtr_2, the address range of the block storage area is str_3 to mtr_3, the address range of the header storage area is str_4 to mtr_4, and the address range of the power storage area is str_5 to mtr_5; wherein, str_1<str_2<str_3<str_4<str_5, and str_2-mtr_1=str_3-mtr_2=str_4-mtr_3=str_5-mtr_4=1; Register No. 1 is used to save the starting address str_1 of area 1, the length L_1 of the target storage area, the write address Addr_S_1 corresponding to the latest data written to the target storage area, and the total write statistics length LEN_1 obtained by counting after the latest data is written to the target storage area; and so on, register No. n is used to save the starting address str_n of area n, the length L_n of the target storage area, the write address Addr_S_n corresponding to the latest data written to the target storage area, and the total write statistics length LEN_n obtained by counting after the latest data is written to the target storage area; among them, the incremental accumulation storage area is named as area 1, the temporary storage area is named as area 2, the block storage area is named as area 3, the header storage area is named as area 4, and the power storage area is named as area 5; The adjustment of the address ranges of the five storage areas, namely, the incremental cumulative storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area, is actually to adjust the four parameters in the registers corresponding to each storage area; the specific adjustment steps are as follows: Step A, after the electric energy meter runs for a preset time, when it detects that the preset condition is met for the x+1th time, it enters the adjustment mode; wherein str_n' is the new starting address of the adjusted area n, L_n' is the new length of the adjusted area n, Addr_S_n' is the write address corresponding to the latest data written to the adjusted area n, LEN_n is the new total length of the written statistics of the adjusted area n; x is a positive integer; When the adjustment mode is detected, the following steps are performed: Step B, when it is detected that the parameters Addr_S_2 and LEN_2 of register No. 2 are adjusted, the parameters str_1 of register No. 1 are set to str_1', the parameter L_1=L_1', the parameter Addr_S_1=str_1', and the parameter LEN_1=0; Step C, after executing step B and detecting that the read operation on area 3 is completed, set the parameter str_2 of register 2 to str_2', parameter L_2 to L_2', parameter Addr_S_2 to str_2', and parameter LEN_2 to 0; and set the parameter str_3 of register 3 to str_3', parameter L_3 to L_3', parameter Addr_S_3 to str_3', and parameter LEN_3 to 0; Step D, after executing step C and detecting that the read operation on area 4 is completed, set the parameter str_4 of register 4 to str_4', the parameter L_4 to L_4', the parameter Addr_S_4 to str_4', and the parameter LEN_4 to 0; Step E, after executing step D and detecting that the read operation of both area 3 and area 4 is completed, set the parameter str_5 of register 5 to str_5', parameter L_5 to L_5', parameter Addr_S_5 to str_5', and parameter LEN_5 to 0; exit the adjustment mode; The method further comprises: After adjusting the address range, data is written to each storage area from the smallest position.
2. The method for managing the operation data of an electric energy meter according to claim 1, characterized in that: The corresponding cumulative result when the preset condition is met for the xth time is used as the xth cumulative power consumption increment, where x is a positive integer; the method further includes: When it is detected that the preset condition is met for the xth time, the xth cumulative power consumption increment is stored in the temporary storage area; The newly acquired pulse increment is accumulated from zero and the accumulated result is stored in the incremental accumulation storage area, so that the accumulated power consumption increment for the x+1th time is obtained when the preset condition is met for the x+1th time.
3. The method for managing the operation data of an electric energy meter according to claim 2, characterized in that: The header part is composed of a header power and a header descriptor corresponding to the header power, and the block part is composed of a block power and a block descriptor corresponding to the block power; When the preset condition is met for the xth time, the total power data in a preset format is generated based on the accumulation result, specifically including: Obtain the x-th cumulative power consumption increment from the temporary storage area; Get the block power in the block part generated when the preset condition is met for the x-1th time; The block power in the block part generated when the preset conditions are met for the x-1th time is added to the cumulative power consumption increment for the xth time to obtain the temporary block power; Generate a block descriptor corresponding to the non-carry portion of the temporary block power; Generate a block portion based on a non-carry portion of the temporary block power and a block descriptor; The temporary block power is added to the head power in the head part generated when the preset condition is met for the x-1th time to obtain the temporary head power; Generate a header descriptor corresponding to the temporary header power; Generates the header part based on the temporary header power and the header descriptor.
4. The method for managing the operation data of an electric energy meter according to claim 3, characterized in that: The intermediate storage area is composed of adjacent block storage areas and header storage areas, and the total power data in a preset format is stored in the intermediate storage area, specifically including: Store the generated block part into the block storage area; The generated header part is stored in the header storage area.
5. The method for managing the operation data of an electric energy meter according to claim 3, characterized in that: Based on Formula 1 Generate the block descriptor P; wherein, is the i-th digit of the block power in the block part, S is the total number of digits of the block power in the block part, % is the modulus operation, and N is the preset modulus; Based on Formula 2 Generate the header descriptor Q; wherein, is the i-th digit of the header power in the header part, T is the total number of digits of the header power in the header part, % is the modulus operation, and N is the preset modulus.
6. The method for managing operation data of an electric energy meter according to claim 1, characterized in that: The length of each storage area is greater than the length of a data written into the storage area, and the method further includes: When writing the first data to the target storage area, write the address str of the first data; When writing the y+1th data to the target storage area, if L-(A_(y)%L)≥M, the address of writing the y+1th data is str + (A_(y) % L); When writing the y+1th data to the target storage area, if L-(A_(y)%L)<M, the address of writing the y+1th data is str; Wherein, y is a positive integer, the target storage area is any storage area among the storage areas, A_(y) is the total length of write statistics obtained after the y-th data is written into the target storage area, L is the length of the target storage area, str is the starting address of the target storage area; and M is the length of the y+1-th data.
7. The method for managing the operation data of an electric energy meter according to claim 6, characterized in that: Determine the total length of write statistics A_(y+1) obtained after the target storage area is written with the y+1th data according to the following steps: If (A_(y) % L) + M ≤ L, then A_(y+1) = A_(y) + M; If (A_(y) % L) + M > L, then A_(y+1) = A_(y) + M +δ; where δ is the correction increment, δ=L-(A_(y) % L).
8. The method for managing operation data of an electric energy meter according to claim 1, characterized in that: If the preset condition is met for the x+1th time, the address range of the five storage areas of the incremental accumulation storage area, the temporary storage area, the block storage area, the header storage area, and the power storage area is adjusted, then the ratio of the lengths of the storage areas after adjustment is determined based on the following formula 3; Formula 3 ; The incremental accumulation storage area is named area 1, the temporary storage area is named area 2, the block storage area is named area 3, the header storage area is named area 4, and the power storage area is named area 5; is the length of the adjusted region k, is the regional characteristic parameter of region k, , k∈{k|1,2,3,4,5}, It is the total length of write statistics obtained after the y-th data is written into area k.
Citation Information
Patent Citations
Electric quantity loss prevention method and device, electric energy meter equipment and storage medium
CN115993940A
High-reliability storage algorithm for photovoltaic equipment
CN117931059A