A method for storing and recovering the tail of an electrical energy pulse

By using FLASH memory and a pulse tail number verification and repair module in smart meters, the problem of lost electricity tail numbers is solved, enabling rapid storage and self-recovery of electricity tail numbers, thus improving metering accuracy and reliability.

CN115904244BActive Publication Date: 2026-05-05JIANGSU TONGCHI POWER AUTOMATION
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JIANGSU TONGCHI POWER AUTOMATION
Filing Date
2022-12-15
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

When the external energy storage components of existing smart meters fail, the tail pulse of the electricity consumption is easily lost, affecting the accuracy of the measurement.

Method used

The system uses FLASH memory to store and restore the power tail pulse. Through a preset pulse tail verification and repair module, combined with the bit operation characteristics of FLASH, it can realize the rapid positioning and self-recovery of the pulse tail.

Benefits of technology

It improves the reliability of the tail pulse of the power consumption, reduces the hardware design cost and difficulty, and meets the State Grid Corporation's resolution requirement of 0.01 kWh.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115904244B_ABST
    Figure CN115904244B_ABST
Patent Text Reader

Abstract

This invention discloses a method for storing and restoring the tail number of electrical energy pulses. The method includes: when the meter is powered on, the metering chip starts measuring according to different load currents, generating pulse signals of different frequencies; when the meter is powered on, a preset pulse tail number verification and repair module performs verification and repair, and updates the successfully repaired pulse tail number to the energy pulse tail number variable Pulse_Int; when the energy pulse tail number variable Pulse_Int is greater than a preset pulse constant or other switching occurs, energy storage is performed immediately; when the accumulated energy pulses after the meter is powered on meet the storage conditions, a preset energy tail number pulse storage module is called, and the storage address of the energy tail number in the FLASH storage device is determined by the currently accumulated pulse count Pulse_Total, completing the energy tail number pulse storage. This invention can quickly locate the tail number pulse in the FLASH and achieve pulse tail number self-recovery, improving reliability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for storing and recovering the tail number of an electrical energy pulse, belonging to the field of smart meter technology. Background Technology

[0002] The promotion and application of smart meters has played a positive role in the development of smart grids and the transformation of electricity management models. However, some problems have also been exposed in the application process. As the meters have been running for a long time, many meters have experienced the problem of losing the last few units of electricity when external energy storage components fail.

[0003] EEPROM is a electrically erasable programmable read-only memory with a maximum erase life of 1 million cycles. This limits its ability to perform data write operations at high frequencies. Electricity consumption is typically stored in EEPROM in whole-unit increments, while higher-frequency data such as the last few kilowatt-hours are stored in RAM and only saved to EEPROM when power is lost. When the meter is abnormally reset or the external energy storage device is damaged (e.g., low battery voltage, capacitor leakage), these last few kilowatt-hours may not be saved in time and are lost, resulting in losses and affecting metering accuracy. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method for storing and restoring the tail number of an electrical energy pulse. This method can quickly locate the tail number pulse in the FLASH memory and realize the self-recovery of the pulse tail number, thereby improving reliability.

[0005] To achieve the above objectives, the present invention is implemented using the following technical solution:

[0006] In a first aspect, the present invention provides a method for storing and recovering the tail number of an electrical energy pulse, comprising:

[0007] When the meter is powered on, the metering chip starts measuring according to the different load currents, generating pulse signals of different frequencies.

[0008] When the meter is powered on, it performs verification and repair through a preset pulse tail number verification and repair module, and updates the successfully repaired pulse tail number to the power pulse tail number Pulse_Int variable.

[0009] After the meter is powered on, an initialization operation is performed, clearing the two variables: Pulse_Total (accumulated power-on pulse count) and Pulse_TotalBak (accumulated power-on pulse count backup).

[0010] When the metering chip generates a pulse, the meter reads the energy register of the metering chip and accumulates the pulses. The number of pulses read is accumulated into the pulse tail number variable Pulse_Int and the power-on accumulated pulse number variable Pulse_Total respectively.

[0011] When the power pulse tail number variable Pulse_Int is greater than the preset pulse constant or other switching occurs, power is stored immediately.

[0012] When the difference between the total number of power-on pulses Pulse_Total and the previous total number of pulses Pulse_TotalBak reaches the preset pulse tail number resolution, the preset power tail number pulse storage module is called. The storage address of the power tail number in the FLASH storage device is determined by the current power-on pulse count Pulse_Total, and the power tail number pulse storage is completed.

[0013] Furthermore, the power-on accumulated pulse count Pulse_Total is used to record the accumulated pulses since the meter was powered on and the storage of the last pulse of the electricity consumption, and the power-on accumulated pulse count backup Pulse_TotalBak is used to record the value of the last pulse of the electricity consumption when the meter stored the last pulse of the electricity consumption.

[0014] Furthermore, the step of immediately storing the battery level when the battery pulse tail number variable Pulse_Int is greater than a preset pulse constant or when other switching occurs includes:

[0015] When the power pulse tail number variable Pulse_Int is greater than the pulse constant C, or when there is a rate switch, daytime schedule switch, time zone switch, or power direction switch, the preset power storage module is called to store the power once. After storage is completed, the Pulse_Int variable is cleared and the count is restarted.

[0016] Furthermore, after each battery tail pulse is stored, the value of Pulse_TotalBak needs to be updated, and Pulse_Total is copied to Pulse_TotalBak.

[0017] Furthermore, the step of determining the storage address of the battery tail in the FLASH storage device by using the current cumulative power-on pulse count Pulse_Total, and completing the storage of the battery tail pulse, includes:

[0018] The memory sector address FlashAddr is determined by calculating the parity of (Pulse_Total / C / 100);

[0019] The integer part of the current electricity energy is obtained by calculating (Pulse_Total / C % 100), and the offset address Offset where the integer part of the pulse is located is determined by calculating (Pulse_Total / C % 100) * 25;

[0020] The tail pulse number that has not filled 1 degree of electricity is determined by calculating (Pulse_Total % C). Since 1 byte stores 0.04C pulses, the specific byte offset address Offset_Byte where the tail of this electricity quantity is stored is determined by calculating (Pulse_Total % C / 0.04C);

[0021] The offset Offset_Bit of the tail of this electricity quantity in the Offset_Byte byte is determined by calculating (Pulse_Total % C / 0.005C);

[0022] Clear the Offset_Bit bit of the Offset_Byte byte, and directly write the data corresponding to 0xFF << Offset_Bit to the address FlashAddr + Offset + Offset_Byte.

[0023] Furthermore, it is judged that Offset is equal to 0 and both Offset_Byte and Offset_Bit are equal to 0, indicating that there is a sector switch, and an erase operation is performed on the previous sector.

[0024] Furthermore, when the storage of the tail pulse of the electricity quantity is completed once, the backup data of the tail pulse of the electricity quantity is updated, and the CRC check code is synchronously refreshed, and then it returns to the normal pulse accumulation process, waiting for the next time to meet the conditions for storing the tail pulse of the electricity quantity.

[0025] Furthermore, the verification by the preset pulse tail verification and repair module includes:

[0026] After power-on, first read the double-backup electricity pulse tail Pulse_Int value in the RAM area and calculate whether its CRC check code is correct. If one of the two is correct, it means that the Pulse_Int value is credible, and it jumps to the stop repair step and no longer performs the subsequent verification and repair operations. The electricity meter enters the normal working state. Only when the CRC check codes of both data are incorrect does the electricity meter enter the electricity tail repair logic;

[0027] The electricity meter enters the electricity repair process, reads the current total forward electricity energy and the current total reverse electricity energy, and calculates the sum of the two, which is the current total electricity energy Pulse_Cur;

[0028] Read the data from the previous two power outage records to obtain the total forward and reverse electrical energy at the time of the power outage recovery of the previous two meters. The sum of the two is the total electrical energy Pulse_Last at the time of the last power-on. If it is the first power outage, then Pulse_Last is set to zero.

[0029] The total number of integer pulses during the last working period is calculated as Pulse_Total = Pulse_Cur - Pulse_Last. The range of the storage address for the last pulse is then deduced from this value.

[0030] Stop the repair process, including: the mantissa pulse verification is available via Pulse_Int, so mantissa pulse recovery is no longer performed;

[0031] The electricity meter enters the electricity module to store electricity.

[0032] Furthermore, the repair process using a preset pulse tail number verification and repair module includes:

[0033] The FLASH sector address FlashAddr and the offset address within the sector Offset are calculated using the integer part of the pulse tail number according to the formula.

[0034] The 25 bytes after Offset represent the pulse tail number of less than one kilowatt-hour. By analyzing this, we can determine the specific bytes and bits where the pulse tail number has been stored.

[0035] Parse the 25 bytes after the offset, find the first 0xFF byte, and then search for the last 0 bit in the byte above it to determine the pulse tail number Pulse_Flash = (Byte-1)*0.04C + Bit*0.005C;

[0036] Read the battery tail pulse Pulse_Eeprom from the EEPROM and verify its CRC. If it is incorrect, directly use the value of Pulse_Flash to recover it. If the CRC is correct, perform a difference comparison. If the difference is within 0.005C pulses, the battery tail pulse stored in the EEPROM is considered reliable, and the value of Pulse_Eeprom is directly used to recover Pulse_Int. Otherwise, the value of Pulse_Eeprom is considered unreliable, and the value of Pulse_Flash is used to recover it.

[0037] The electricity meter enters the electricity module to store electricity.

[0038] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:

[0039] This invention provides a method for storing and recovering the tail number of an electrical energy pulse. Combining the advantages of FLASH memory, such as large capacity, high reliability, fast bit operation programming speed, and no impact on FLASH lifespan, a highly reliable electrical energy tail number pulse storage, verification, and recovery technology based on FLASH bit operation is proposed. By combining a highly reliable FLASH storage device with a simple and reliable storage and recovery algorithm, the software self-recovery function of the electrical energy tail number pulse is realized, which can greatly reduce the hardware design cost and design difficulty when solving this problem. Attached Figure Description

[0040] Figure 1 This is a schematic diagram of a FLASH memory storing a 0.04C power pulse in one byte, provided in an embodiment of the present invention.

[0041] Figure 2 This is a schematic diagram of the power processing module workflow provided in an embodiment of the present invention;

[0042] Figure 3 This is a schematic diagram of the working process of the power tail pulse storage module provided in an embodiment of the present invention;

[0043] Figure 4 This is a schematic diagram of the workflow of the pulse tail number verification and repair module provided in the embodiment of the present invention. Detailed Implementation

[0044] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.

[0045] Example 1

[0046] The method for storing and recovering the tail of an electrical energy pulse provided in this embodiment involves the following steps in its application:

[0047] 1. Principle of FLASH area power digit storage

[0048] (1) Advantages of FLASH memory in storing tail pulses

[0049] 1) Good bit operability

[0050] Flash memory operates based on programming / erasing logic. Writing to the flash (programming) involves controlling the control gate to charge it, ensuring the floating gate stores enough charge to exceed the threshold Vth, which represents a 0. Erasing the flash (erase) involves discharging the floating gate; if the charge falls below the threshold Vth, it represents a 1. Flash memory controls the floating gate's charge bit by bit; that is, the process from 1 to 0 only requires charging, while the process from 0 to 1 requires erasing to perform a discharge.

[0051] Fast byte write speed

[0052] The typical time for writing one byte of FLASH is only 10us. Its fast programming speed is particularly suitable for application scenarios that require power loss retention. By matching a suitable algorithm, reliable storage of the tail of the power pulse can be achieved.

[0053] (2) FLASH storage space design

[0054] Assuming the meter's pulse constant is C, and the FLASH sector is 4096 bytes, after erasing the sector, all bytes will be 0xFF. Each bit in each byte represents the number of pulses for 0.005 kWh, i.e., 0.005C. If the meter's pulse constant is 2000 imp / kWh, meaning 2000 pulses represent 1 kWh, then 0.005 kWh requires 10 pulses. If the meter's pulse constant is 1200 imp / kWh, then 0.005 kWh requires 6 pulses. Therefore, one byte can represent 0.04 kWh, and 25 bytes represent 1 kWh. This paper only uses 2500 bytes as the pulse tail number storage space, meaning one sector can store a maximum of 100 kWh of pulse tail numbers. To reduce the number of times the FLASH can be erased and rewritten, two consecutive FLASH sectors are used for storing the last 100 seconds of power in the first sector and the last 100 seconds in the second sector. This process is repeated, which can reduce the number of times the FLASH can be erased and rewritten by half.

[0055] (3) Principle of energy tail pulse storage

[0056] The FLASH pulse mantissa storage frequency is 0.005 kWh, or 0.005C pulses, represented by 1 bit of 1 byte. Therefore, each byte of the FLASH storage unit can represent 0.04 kWh. (The rest of the text is missing.) Figure 1 This indicates that the FLASH uses one byte to store the change in the tail number pulse of 0.04 kWh of electricity.

[0057] S0-1: After the FLASH is erased, all storage spaces are 0xFF, which corresponds to the binary number 11111111.

[0058] S0-2: After 0.005C pulses, the storage resolution is reached, and the BIT0 bit of the first byte of FLASH is cleared to 0, that is, 0xFF becomes 0xFE, corresponding to the binary number 11111110.

[0059] S0-3: After another 0.005C pulses, the storage resolution is reached. Bit 1 of the first byte of FLASH is cleared to 0, that is, 0xFE becomes 0xFC, corresponding to the binary number 11111100.

[0060] S0-6: This process repeats until, after a total of 0.04C pulses, the first byte of the FLASH changes from 0xFF to 0. If there are subsequent pulses, the second byte of the sector is stored according to the same storage principle. That is, every 25 bytes is a pulse of 1 kilowatt-hour, until the sector is full of 100 kilowatt-hours and then the system switches to the next sector. Every 100 kilowatt-hours occupies the first 2500 bytes of the storage sector.

[0061] 2. Power Processing Module Workflow

[0062] (1) Power processing module workflow

[0063] as follows Figure 2 As shown, the meter is powered on and accumulates pulses until the energy pulses meet the storage conditions, and then the energy accumulation and pulse tail count are accumulated respectively.

[0064] S1-0: The meter is powered on. Depending on the load current, the metering chip starts measuring and generates pulse signals of different frequencies. Each time a pulse signal is generated, the meter will generate a level from the pulse output port of the metering chip. The meter MCU can obtain this level through polling or interrupt.

[0065] S1-1: Upon power-up, the meter enters the pulse tail count verification and repair module. The specific process of the module is as follows: Figure 4 As shown, if the verification passes, there is no need to enter the pulse tail number repair process; otherwise, the pulse tail number repair process will be entered and successfully repaired, updating the pulse tail number to the power pulse tail number variable Pulse_Int. This value is double-backup data with CRC verification and is self-repairing. The Pulse_Int variable is used to store the power pulse tail number. Power is stored when the pulse number reaches the pulse constant C or when there are situations such as rate switching, day / hour table switching, time zone switching, or power direction switching. After each storage, it will be cleared to zero and re-accumulated.

[0066] S1-2: After power-on, the system performs an initialization operation, clearing two variables: Pulse_Total (accumulated power pulse count) and Pulse_TotalBak (power-on backup accumulated pulse count). These variables are 4 bytes of data in the RAM area, with double backup data including CRC checksum, allowing for self-recovery in case of data distortion. Pulse_Total records the pulses accumulated by the meter since power-on and is used for storing the last pulse of the power consumption. This value determines the specific storage location of the last pulse of the power consumption in the FLASH memory. Pulse_TotalBak records the value of the last pulse of the power consumption when the meter last stored it. When the difference between Pulse_Total and Pulse_TotalBak reaches 0.005 kWh, the last pulse of the power consumption is stored.

[0067] S1-3: When the metering chip generates a pulse, the meter MCU will read the energy register of the metering chip and accumulate the pulse. To prevent the meter from measuring normally due to hardware failure, a maximum timeout of 8 seconds is set. Even if no pulse is generated, the meter MCU will still read the energy register in the metering chip.

[0068] S1-4: The number of pulses read is accumulated into the pulse tail number variable Pulse_Int and the power-on accumulated pulse number variable Pulse_Total, and the CRC check code is updated and synchronized to the dual backup data area.

[0069] S1-5: When the power pulse tail number variable Pulse_Int is greater than the pulse constant C, or when the meter current direction changes, the rate number changes, or the time zone or time period meter number changes, power storage is performed immediately by calling the power storage module. After storage, the Pulse_Int variable is cleared and the count is restarted. The power storage logic is relatively mature and is not the focus of this article.

[0070] S1-7: When the difference between the total number of cumulative pulses Pulse_Total and the previous total number of cumulative pulses Pulse_TotalBak reaches a pulse tail number resolution of 0.005 kWh, the power tail number pulse storage logic is called to store the power tail number pulse once. After storage, the value of Pulse_TotalBak needs to be updated, and Pulse_Total is copied to Pulse_TotalBak.

[0071] S1-8: After the last bit of the power pulse is stored, return to step S1-3 to continue pulse accumulation and repeat the above process.

[0072] (2) Battery tail pulse storage module

[0073] The power count storage module uses an algorithm to quickly determine the storage address in the FLASH storage device of the current cumulative power-on pulse count (Pulse_Total). The algorithm is as follows: Figure 3 As shown, C represents the meter pulse constant.

[0074] S2-1: Determine the FlashAddr sector address for battery storage: Since the FLASH has two sectors for storing the battery tail pulse, and each sector stores 1 kilowatt-hour of battery (25 bytes), each sector can store a maximum of 100 bytes. The storage sector address FlashAddr can be determined by the parity of (Pulse_Total / C / 100).

[0075] S2-2: Determine the offset address Offset of the power in the sector: (Pulse_Total / C % 100) can calculate the integer part of the current power consumption. Since each degree of electricity occupies 25 bytes, (Pulse_Total / C % 100)*25 can determine the offset address Offset where the integer part of the pulse is located.

[0076] S2-3: Determine the specific position Offset_Byte of the mantissa pulse in 25 bytes: Pulse_Total % C can determine the number of mantissa pulses that have not filled 1 degree of electricity. Since 1 byte stores 0.04C pulses, Pulse_Total % C / 0.04C can determine the specific byte offset address Offset_Byte where the mantissa of the power is stored.

[0077] S2-4: Determine the bit address Offset_Bit of the mantissa pulse in the byte address of Offset_Byte: Since each Bit of 1 byte represents 0.005 degrees of electricity, that is, 0.005C pulses, Pulse_Total % C / 0.005C can determine the offset Offset_Bit of the mantissa of the power in this Offset_Byte byte.

[0078] S2-5: Clear the Offset_Bit bit of the mantissa pulse in the Offset_Byte byte: That is, clear the Offset_Bit bit of the Offset_Byte byte, and directly write the data corresponding to 0xFF << Offset_Bit to the address of FlashAddr + Offset + Offset_Byte.

[0079] S2-6: If the sector is switched, erase the previous sector: Judge that Offset is equal to 0 and both Offset_Byte and Offset_Bit are equal to 0, indicating that there is a sector switch, and perform an erase operation on the previous sector.

[0080] S2-7: Refresh the data in the backup area of the mantissa pulse of the power: The mantissa pulse of the current power has been stored. It is necessary to update the backup data of the mantissa pulse of the power and synchronously refresh the CRC check code. Finally, return to the normal pulse accumulation process and wait for the next time to meet the storage conditions of the mantissa pulse of the power.

[0081] (3) Pulse mantissa verification and repair module

[0082] After the power meter is powered on, it immediately enters the pulse mantissa verification and repair module. It will enter the normal working state only after the power is repaired. The specific repair process of the pulse mantissa is as follows.

[0083] S3-1: After power-on, first read the Pulse_Int value of the dual backup power pulse in the RAM area and calculate whether its CRC check code is correct. If one of the two is correct, it means that the Pulse_Int value is reliable. Jump to step S3-5 and no longer perform subsequent verification and repair operations. The meter enters normal working state. Only when the CRC check codes of both data are incorrect will the meter enter the power pulse repair logic.

[0084] S3-2: The meter enters the power restoration process, reads the current forward total energy and the current reverse total energy, and calculates the sum of the two, which is the current total energy Pulse_Cur.

[0085] S3-3: Read the data from the previous two power outage records to obtain the total forward and reverse electrical energy at the time of power recovery from the previous two power outages. The sum of these two values ​​is the total electrical energy Pulse_Last at the time of the last power-on. If it is the first power outage, Pulse_Last is set to zero.

[0086] S3-4: Calculate the total number of integer pulses during the previous working period as Pulse_Total = Pulse_Cur - Pulse_Last. The range of the storage address for the last pulse can be deduced from this value.

[0087] S3-5: The mantissa pulse verification is available via Pulse_Int, so mantissa pulse recovery is no longer required.

[0088] S3-6: The meter enters the power module to store the power consumption.

[0089] S3-7 to S3-8: The calculation process is similar to the pulse tail number storage process. Both calculate the FLASH sector address FlashAddr and the offset address Offset within the sector by using the integer part of the pulse tail number according to the formula.

[0090] S3-9: The 25 bytes after Offset are the pulse tail number of less than one kilowatt-hour. Only by analyzing them can we determine that the pulse tail number has been stored in the specific byte and specific bit.

[0091] S3-10: Since the pulse tail number storage process is stored bit by bit according to the pulse period of 0.005C, it is only necessary to parse the 25 bytes, find the first 0xFF position Byte, and then search for the last 0 bit Bit in the previous byte. The pulse tail number Pulse_Flash = (Byte-1)*0.04C + Bit*0.005C can be determined.

[0092] S3-11 to S3-13: Repair and reverse verification process of the tail pulse. First, read the battery tail pulse Pulse_Eeprom from the EEPROM and verify its CRC. If it is incorrect, directly use the value of Pulse_Flash for recovery. If the CRC is correct, perform a difference comparison. If the difference is within 0.005C pulses, the battery tail pulse stored in the EEPROM is considered reliable, and the value of Pulse_Eeprom is directly used for recovery of Pulse_Int. Otherwise, the value of Pulse_Eeprom is considered unreliable, and the value of Pulse_Flash is used for recovery.

[0093] This embodiment combines the advantages of FLASH memory, such as large capacity, high reliability, fast bit-operation programming speed, and no impact on FLASH lifespan. This paper proposes a FLASH bit-operation-based technology for storing and verifying the last digit pulse of electricity consumption. By splitting the integer and fractional parts of the last digit of the electricity consumption pulse and setting a simple and reliable storage algorithm, automatic addressing of the corresponding storage sector and the offset addresses of bytes and bits within the sector can be achieved. Storage with a period of 0.005 kWh last digit pulses is realized, which is lower than the State Grid Corporation's requirement of 0.01 kWh resolution. To address potential anomalies in the last digit pulse data, this paper proposes a complete method to quickly locate the last digit pulse position in the FLASH memory and achieve pulse last digit self-recovery, thus improving reliability.

[0094] This paper proposes a technology for storing, verifying, and recovering battery tail pulses, taking advantage of the large storage capacity, high reliability, fast bit-operation programming speed, and lack of impact on FLASH lifespan. Theoretically, this function can also be achieved by replacing the FLASH memory with EEPROM memory and modifying the corresponding operation algorithm. However, since EEPROM lacks bit-operation capabilities, a larger EEPROM storage space must be sacrificed in exchange for erase / write lifespan, resulting in a slower storage speed compared to this method.

[0095] 1. Explanation of technical terms:

[0096] (1) EEPROM: (Electrically Erasable Programmable Read-Only Memory) refers to electrically erasable programmable read-only memory. It is a type of memory chip that does not lose data after power failure.

[0097] (2) FLASH: A type of memory device, which is a non-volatile memory, specifically divided into NOR-FLASH and NADN-FLASH.

[0098] 2. Explanation of some key English variables

[0099] (1) C: The pulse constant of the meter, such as 1200imp / kWh, which means that 1200 pulses are needed to generate 1 kWh of electricity.

[0100] (2)Pulse_Int: The last pulse number of the meter, with CRC check and double backup, which will be cleared after each storage.

[0101] (3)Pulse_Total: The power meter's cumulative pulse count represents all the pulses accumulated from power-on to power-off. It is represented by 4 bytes, with CRC check and double backup. This value is only cleared when the meter is powered on.

[0102] (4) Pulse_TotalBak: The cumulative pulse backup of the meter upon power-on, represented by 4 bytes, with CRC check and double backup. When the difference between Pulse_Total and Pulse_TotalBak is greater than 0.005 kWh, the tail pulse storage will be started once. After storage is completed, the Pulse_TotalBak value will be updated once.

[0103] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for storing and recovering the tail number of an electrical energy pulse, characterized in that, Including: When the electricity meter starts to power on, according to different load currents, the metering chip starts to measure and generates pulse signals with different frequencies; When the electricity meter powers on, it is verified and repaired through a preset pulse mantissa verification and repair module, and the successfully repaired pulse mantissa is updated to the electricity quantity pulse mantissa Pulse_Int variable; After the electricity meter powers on, initialization operations are performed to clear the two variables of the power-on cumulative pulse count Pulse_Total and the backup of the power-on cumulative pulse count Pulse_TotalBak; When the metering chip generates a pulse, the electricity meter reads the energy register of the metering chip and accumulates the pulse, and the read pulse counts are respectively accumulated into the pulse mantissa variable Pulse_Int and the power-on cumulative pulse count Pulse_Total variable; When the electricity quantity pulse mantissa variable Pulse_Int is greater than the preset pulse constant or there are other switches, an electricity quantity storage is immediately performed; When the difference between the power-on cumulative pulse total Pulse_Total and the previous cumulative pulse total Pulse_TotalBak reaches the preset pulse mantissa resolution, the preset electricity quantity mantissa pulse storage module is called, and the storage address of the electricity quantity mantissa in the FLASH storage device is determined by the current power-on cumulative pulse count Pulse_Total, and the electricity quantity mantissa pulse storage is completed, including: Determine the storage sector address FlashAddr by calculating the parity of (Pulse_Total / C / 100); Obtain the integer part of the current electric energy by calculating (Pulse_Total / C%100), and determine the offset address Offset where the pulse integer part is located by calculating (Pulse_Total / C%100)*25; Determine the mantissa pulse count that has not reached 1 degree of electricity by calculating (Pulse_Total%C). Since 1 byte stores 0.04C pulses, determine the specific byte offset address Offset_Byte where the electricity quantity mantissa is stored by calculating (Pulse_Total%C / 0.04C); Determine the offset Offset_Bit of the electricity quantity mantissa in the Offset_Byte byte by calculating (Pulse_Total%C / 0.005C); Clear the Offset_Bit bit of the Offset_Byte byte, and directly write the data corresponding to 0xFF<<Offset_Bit to the address FlashAddr+Offset+Offset_Byte; 2. The method for storing and recovering the tail number of an electrical energy pulse according to claim 1, characterized in that, The power-on cumulative pulse count Pulse_Total is used to record the pulses accumulated by the electricity meter since power-on and the storage of the electricity quantity mantissa pulses, and the backup of the power-on cumulative pulse count Pulse_TotalBak is used to record the value when the electricity meter last stores the electricity quantity mantissa pulses; 3. The method for storing and recovering the tail number of an electrical energy pulse according to claim 1, characterized in that, When the electricity quantity pulse mantissa variable Pulse_Int is greater than the preset pulse constant or there are other switches, an electricity quantity storage is immediately performed, including: When the power pulse tail number variable Pulse_Int is greater than the pulse constant C, or when there is a rate switch, daytime schedule switch, time zone switch, or power direction switch, the preset power storage module is called to store the power once. After storage is completed, the Pulse_Int variable is cleared and the count is restarted.

4. The method for storing and recovering the tail number of an electrical energy pulse according to claim 1, characterized in that, Each time the last pulse of the battery charge is stored, the value of Pulse_TotalBak needs to be updated after storage, and Pulse_Total is copied to Pulse_TotalBak.

5. The method for storing and recovering the tail number of an electrical energy pulse according to claim 1, characterized in that, If Offset equals 0 and both Offset_Byte and Offset_Bit are equal to 0, it indicates that a sector switch has occurred, and the previous sector will be erased.

6. The method for storing and recovering the tail number of an electrical energy pulse according to claim 1, characterized in that, Once a battery charge tail pulse is stored, the backup data for the battery charge tail pulse is updated, and the CRC checksum is refreshed simultaneously. The process then returns to the normal pulse accumulation process, waiting for the next time the battery charge tail pulse storage condition is met.

7. The method for storing and recovering the tail number of an electrical energy pulse according to claim 1, characterized in that, The verification process, performed via a preset pulse tail number verification and repair module, includes: After power-on, the Pulse_Int value of the dual backup power pulse tail in the RAM area is read and its CRC check code is calculated to see if it is correct. If one of the two is correct, it means that the Pulse_Int value is reliable. Jump to the stop repair step and no longer perform subsequent verification and repair operations. The meter enters normal working state. Only when the CRC check codes of both data are incorrect will the meter enter the power tail repair logic. The meter enters the power restoration process, reads the current total forward power and the current total reverse power, and calculates the sum of the two, which is the current total power Pulse_Cur; Read the data from the previous two power outage records to obtain the total forward and reverse electrical energy at the time of the power outage recovery of the previous two meters. The sum of the two is the total electrical energy Pulse_Last at the time of the last power-on. If it is the first power outage, then Pulse_Last is set to zero. The total number of integer pulses during the last working period is calculated as Pulse_Total = Pulse_Cur - Pulse_Last. The range of the storage address for the last pulse is then deduced from this value. Stop the repair process, including: the mantissa pulse verification is available via Pulse_Int, so mantissa pulse recovery is no longer performed; The electricity meter enters the electricity module to store electricity.

8. The method for storing and recovering the tail number of an electrical energy pulse according to claim 1, characterized in that, The repair process, performed using a preset pulse tail number verification and repair module, includes: The FLASH sector address FlashAddr and the offset address within the sector Offset are calculated using the integer part of the pulse tail number according to the formula. The 25 bytes after Offset represent the pulse tail number of less than one kilowatt-hour. By analyzing this, we can determine the specific bytes and bits where the pulse tail number has been stored. Parse the 25 bytes after the offset, find the first 0xFF byte, and then search for the last 0 bit in the byte above it to determine the pulse tail number Pulse_Flash = (Byte-1)*0.04C + Bit*0.005C; Read the battery tail pulse Pulse_Eeprom from the EEPROM and verify its CRC. If it is incorrect, directly use the value of Pulse_Flash to recover it. If the CRC is correct, perform a difference comparison. If the difference is within 0.005C pulses, the battery tail pulse stored in the EEPROM is considered reliable, and the value of Pulse_Eeprom is directly used to recover Pulse_Int. Otherwise, the value of Pulse_Eeprom is considered unreliable, and the value of Pulse_Flash is used to recover it. The electricity meter enters the electricity module to store electricity.

Citation Information

Patent Citations

  • Electric quantity data storage method for electric energy meter

    CN105334383A

  • Freeze data storage method of electric energy meter based on FLASH pre-erasing technology and electric energy meter

    CN114356792A