Ammeter upgrading method for maintaining pulse frequency and metering stability
By employing upgrade partitioning and pulse idle writing technology in the electricity meter, the problems of metering function interruption and inconsistent electricity consumption data during the meter upgrade process are solved, ensuring the stability of pulse frequency and the continuity of metering accuracy during the meter upgrade process, and achieving high efficiency and accuracy in the meter upgrade.
Patent Information
- Application Number
- CN202511753582.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-03-20
AI Technical Summary
Existing electricity meter upgrade technologies struggle to balance the continuity of metering functions with the integrity of electricity consumption data, leading to issues such as interrupted pulse output and inconsistent electricity consumption data.
By employing upgrade partitioning and pulse idle writing technology, the meter receives upgrade commands and performs security verification through the built-in communication module. It utilizes SRAM to temporarily take over the metering function, combined with partition comparison and pulse status monitoring, to achieve fragmented downloading and fragmented writing of firmware, ensuring uninterrupted metering function and data accuracy.
This ensures the stability of pulse frequency and the continuity of metering accuracy during the meter upgrade process, avoiding metering interruptions and loss of electricity data, and improving upgrade efficiency and data accuracy.
Smart Images

Figure CN121704864A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart meter technology, and specifically to a method for upgrading smart meters to maintain pulse frequency and metering stability. Background Technology
[0002] With the continuous development of smart grids, electricity meters need to undergo firmware upgrades remotely or locally to meet the dynamic needs of grid operation. This includes supporting new feature expansions and fixing system vulnerabilities. This upgrade requirement has become a crucial aspect of smart meter operation and maintenance. Currently, existing technologies for electricity meter upgrades mainly fall into two categories:
[0003] (1) Shutdown upgrade technology: This technology requires first suspending the metering function of the electricity meter, and then starting the firmware writing and program update operation. After the upgrade is completed, the metering function is restored. Its main idea is to avoid program conflicts during the upgrade process by stopping first and then upgrading, but it does not consider the need for metering continuity.
[0004] (2) Dual backup partition upgrade technology: This technology sets up two redundant firmware partitions in the meter's storage chip, a primary partition and a backup partition. During the upgrade, the new firmware is first written to the backup partition. After completion, the new firmware is activated through program switching, while the old firmware is retained to support upgrade rollback. Its core advantage is improved upgrade reversibility, but the metering module operation mechanism during the new firmware activation phase is not optimized.
[0005] It is evident that existing technologies have some problems in practical applications, making it difficult to balance the needs of meter upgrades with metering stability. These problems can be summarized as follows:
[0006] (1) Metering function interruption problem: During the upgrade process, the chip will stop or delay the execution of the interrupt program when performing Flash write operation, which will cause the meter pulse output function to stagnate, resulting in no pulse output or increased metering accuracy error. Although the dual backup partition upgrade technology can retain the old firmware, it will still temporarily stop the metering function and pulse output when the new firmware is activated and switched, which cannot meet the critical requirement of real-time operation of the metering module.
[0007] (2) Inconsistent electricity data: The existing upgrade process generally requires restarting the electricity meter system to complete the loading of the new firmware. The restart process will cause the loss of electricity data during the upgrade, which will damage the integrity of the user's electricity data and affect the accuracy of subsequent electricity billing and electricity data analysis.
[0008] Therefore, a technical solution is needed that can maintain stable pulse frequency throughout the upgrade process, ensure continuous operation of metering functions, and guarantee accurate electricity consumption data. Summary of the Invention
[0009] To address the aforementioned problems in existing technologies, this invention employs upgrade partitioning and pulse idle writing techniques to propose a method for upgrading electricity meters that maintains pulse frequency and metering stability, comprising the following steps:
[0010] S1: Receive firmware upgrade instructions from the remote operation and maintenance platform through the built-in communication module of the electricity meter, verify the legality of the instructions, download the firmware in standard segments and enable breakpoint resume, and perform security verification on the firmware after completion.
[0011] S2: Based on the partition architecture of driver area and application area, the upgrade scope is determined by partition comparison. If the driver area needs to be upgraded, the metering core program is copied to SRAM to temporarily take over the metering function. After the driver area is written, it is switched back to the new Flash driver area.
[0012] S3: Calculates the minimum pulse interval based on the instantaneous power of the electricity meter and the pulse constant, adapts to the Flash single block write time, monitors the pulse status in real time, and writes the application area firmware into Flash in fragments during the pulse idle period.
[0013] S4: After the upgrade, the functions and metrological stability are verified. The application area functions are fully checked and the metrological accuracy is graded and verified. After completion, the system is switched to the new firmware.
[0014] Preferably, step S1 includes:
[0015] S11: The meter's main control unit (MCU) parses the instructions, extracts the firmware version number, platform digital signature, and instruction issuance time, verifies the validity of the digital signature using the locally stored platform public key, checks whether the new firmware version number is higher than the current version, and checks whether the instruction issuance time exceeds the threshold from the current time.
[0016] S12: Divide the external Flash storage chip into a temporary storage area and a target upgrade area, download the firmware in standard segments, record the progress after each data storage block is completed during the download process, and continue downloading from the breakpoint after network interruption is restored;
[0017] S13: After all fragments have been downloaded, a verification is performed. If the verification fails, the temporary storage area is cleared and a re-download is requested. If the verification passes, the firmware fragments are transferred to the target upgrade area.
[0018] Preferably, step S2 includes:
[0019] S21: Compare the driver area of the previous firmware with the driver area of the new firmware, match the application area of the previous firmware with the application area of the new firmware, and distinguish between three upgrade scenarios: only upgrade the application area, prioritize upgrade the driver area, and upgrade the driver area first and then the application area.
[0020] S22: Copy the core metering program in the driver area to SRAM and pass the verification. Switch the metering function execution carrier from Flash to SRAM. After the new driver area is written in slices and verified block by block, switch the metering function back to the new driver area and release SRAM.
[0021] S23: Regardless of whether the driver area is upgraded, the new firmware application area is marked as "pending upgrade" and the read and write permissions of the application area are locked, allowing only the upgrade process to operate on it.
[0022] Preferably, step S3 includes:
[0023] S31: Calculate the minimum pulse interval time T; read the Flash single block write time. If T is greater than the write time, write according to the original block size. If T is less than the write time, reduce the fragment size.
[0024] S32: Set the interrupt priority of the pulse monitoring program to the highest level, determine the "pulse output period" by the rising edge of the pulse interrupt signal of the metering chip, and send a pause signal to the Flash write control module; determine the "pulse idle period" by the falling edge, send a write permission signal and record the write progress;
[0025] S33: During the pulse idle period, write the application area firmware according to the appropriate fragment size. Perform local verification after each fragment is written until all fragments are written and verified.
[0026] Preferably, step S4 includes:
[0027] S41: Start all upper-layer functions in the application area in a preset order, verify the display function, communication function, and user interaction function. If any function is abnormal, switch back to the old firmware and report the faulty module.
[0028] S42: Perform continuous metering verification, compare the cumulative power consumption deviation, pulse output consistency, and pulse frequency stability. If the accuracy does not meet the standard, switch back to the old firmware and provide feedback.
[0029] S43: After the function and accuracy verification is qualified, switch to the new firmware and send an upgrade success log to the platform; start long-term sampling monitoring, collect and store metering data and functional status every hour, and upload the data to the platform for potential hazard analysis after the monitoring ends.
[0030] Preferably, the formula for calculating the minimum pulse interval time T is T=3600×1000 / (C×P), where C is the meter pulse constant and P is the instantaneous power collected in real time by the metering chip.
[0031] Preferably, step S33 further includes performing a second pulse state detection: if the device is still idle after writing a block, writing continues; if a rising edge is detected, writing stops.
[0032] Preferably, in step S21, the comparison uses the SHA256 hash algorithm.
[0033] Preferably, in S13, the verification includes CRC32 cyclic redundancy check and SHA256 hash check.
[0034] The present invention has the following beneficial effects:
[0035] (1) By designing a partitioned architecture for the driver area and the application area, and combining it with the mechanism of SRAM temporarily taking over the metering function, the uninterrupted operation of the metering core program is achieved during the upgrade. When the driver area is upgraded, the metering core program is copied to SRAM and the execution carrier is switched to ensure that the metering operation and pulse generation are not interrupted. The application area upgrade adopts pulse idle writing technology, which calculates the minimum pulse interval based on instantaneous power and pulse constant, dynamically adapts to the Flash slice write size, avoids conflict between Flash write operation and pulse interruption, and finally achieves no deviation in pulse frequency and meets the metering accuracy requirements throughout the upgrade process.
[0036] (2) A full-process data protection system is constructed through multiple security mechanisms. The legality of the upgrade command is verified during the upgrade command stage to avoid the execution of illegal commands. Standard fragmentation and breakpoint resumption are adopted during the firmware download stage to deal with network interruption scenarios and reduce the consumption of resources by repeated transmission. After the upgrade, continuous metering verification is also carried out to check the cumulative power consumption deviation, pulse output consistency and frequency stability to ensure that the data after the upgrade is accurate.
[0037] (3) Based on partition hash comparison, three upgrade scenarios are identified, and upgrades are performed only on the differences in the driver area or application area, without requiring a full firmware update, which greatly reduces the amount of upgrade data and resource consumption. Among them, when only the application area is upgraded, the driver area can continue to run without affecting the metering function. When both the driver area and the application area need to be upgraded, the upgrade is performed in stages to avoid system resource conflicts caused by simultaneous operations, thereby improving upgrade efficiency and reducing system load.
[0038] The electricity meter upgrade method of the present invention can effectively solve the problems of metering interruption, pulse frequency deviation, and data inconsistency during electricity meter upgrades in the prior art. Attached Figure Description
[0039] Figure 1 This is a diagram illustrating the method steps of an embodiment of the present invention;
[0040] Figure 2 This is a schematic diagram illustrating the software pulse interruption response time delay in an embodiment of the present invention.
[0041] Figure 3 This is a schematic diagram of the pulse output idle writing method in an embodiment of the present invention;
[0042] Figure 4 This is a schematic diagram illustrating the partitioning of the driver area and the application area in an embodiment of the present invention;
[0043] Figure 5 This is a flowchart of the pulse output idle state writing method according to an embodiment of the present invention. Detailed Implementation
[0044] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0045] This embodiment presents a method for upgrading electricity meters to maintain stable pulse frequency and metering. Taking remote OTA (Over-The-Air) upgrades of smart meters as a scenario, it focuses on firmware partitioning and pulse idle state writing technologies. It clearly defines the detailed steps of the upgrade process, anomaly handling mechanisms, and stability assurance measures to ensure uninterrupted metering function, consistent pulse frequency, and data accuracy meeting industry standards throughout the upgrade process. Figure 1 As shown, the method includes the following steps:
[0046] S1: Upgrade Command Reception and New Firmware Security Preprocessing. The meter has a built-in communication module that supports multiple standards such as NB-IoT, LoRa, Ethernet, and 4G / 5G, adapting to different power grid coverage scenarios. It receives firmware upgrade commands from the remote operation and maintenance platform via the communication module. This step addresses issues such as command validity, firmware security, and download reliability.
[0047] S11: Upgrade Command Legality Verification. The meter's main control unit (MCU) first parses the command content, extracting key information such as the firmware version number, command issuance time, and platform digital signature. It verifies the validity of the digital signature by comparing it with the locally stored platform public key, preventing unauthorized third parties from issuing forged commands. Simultaneously, it checks if the new firmware version number is higher than the currently running version. If the version number is the same or lower, it sends a "no upgrade needed" signal to the platform to avoid redundant operations and resource consumption. If the command issuance time is more than 72 hours from the current time, the command is deemed expired, execution is refused, and a request is made to the platform to reissue the command.
[0048] S12: Firmware Download and Segmented Storage. After successful verification, the MCU initiates the initialization process of the external Flash storage chip, dividing it into a temporary storage area for storing unverified firmware data and a target upgrade area for subsequent final firmware writing. Based on the block storage characteristics of the external Flash and the actual program design, the firmware file can be downloaded in segments of 256 bytes / page. Considering that the total upgrade package size is generally around 384KB, a full upgrade requires multiple Flash page writes and block erases. A breakpoint resume mechanism is enabled during the download process. If the network is interrupted, such as due to a weak NB-IoT signal, the MCU records the current progress after each data segment is downloaded, and resumes downloading from the breakpoint after the connection is restored, without needing to re-acquire the complete firmware.
[0049] S13: Firmware Security Verification. After all fragments are downloaded, the MCU performs dual verification to ensure firmware integrity and security. The first verification is CRC32 cyclic redundancy check, which calculates the checksum of the entire firmware data and compares it with the baseline value issued by the platform to check for bit errors in data transmission. The second verification is SHA256 hash check, which verifies that the firmware hash value is consistent with the pre-stored value on the platform to prevent the firmware from being tampered with during transmission or storage. If either verification fails, the MCU clears the temporary storage area and reports "firmware corrupted" to the platform, triggering a re-download process until both verifications pass. Then, the firmware fragments are transferred from the temporary storage area to the target upgrade area for processing.
[0050] S2: Firmware partition comparison and driver upgrade guarantee. For example... Figure 4 As shown, a partitioned architecture is set up with a driver area and an application area. The driver area stores the underlying driver and metering core program, while the application area stores the upper-level function program. The upgrade scope is clarified by partition comparison, and the focus is on solving the metering continuity problem when upgrading the driver area, so as to avoid metering interruption due to driver updates.
[0051] S21: Partition Hash Comparison. The MCU reads the code hash values of the driver and application areas in the currently running firmware, which can be generated using the SHA256 algorithm. These hash values are then compared one by one with the hash values of the corresponding partitions in the new firmware, resulting in three upgrade scenarios:
[0052] (1) The hash values of the driver area are consistent, but those of the application area are inconsistent: only the application area is upgraded, the driver area continues to run, and the metering function is not affected.
[0053] (2) The hash values of the driver area are inconsistent, while those of the application area are consistent: the driver area should be upgraded first, and then the current state of the application area should be maintained.
[0054] (3) The hash values of the two are inconsistent: upgrade the driver area first, then upgrade the application area, and execute in stages to avoid resource conflicts.
[0055] S22: Driver area upgrade to ensure metering continuity. If a driver area upgrade is required, the MCU first initiates the preparation process for its internal static RAM (SRAM). Select an SRAM with a capacity of at least 256KB, matching the size of the metering core program (typically 100KB-200KB) to ensure no metering data is lost during the upgrade. Specific steps are as follows:
[0056] (1) Copying and verification: Copy the metering core program in the current driver area to SRAM completely. After copying, verify the program in SRAM with CRC16 to ensure that it is consistent with the original driver area program, so as to avoid metering abnormalities caused by copying errors.
[0057] (2) Switching the metering execution carrier: The MCU switches the metering function execution carrier from the Flash drive area to the SRAM. At this time, the SRAM temporarily takes over the metering calculation and pulse generation functions, and the frequency and accuracy of the output pulse signal remain unchanged.
[0058] (3) Driver area writing and switching back: The driver area of the new firmware is written to the Flash driver area in blocks. After each block is written, a CRC check is performed to ensure the integrity of the driver area program. After all blocks are written, the MCU switches the metering function from SRAM back to the new Flash driver area, freeing up SRAM space and avoiding long-term occupation that would lead to increased power consumption, thus completing the driver area upgrade.
[0059] S23: Application Area Upgrade Mark. Regardless of whether the driver area is upgraded, the MCU marks the application area of the new firmware as "pending upgrade" and locks the read and write permissions of the application area, allowing only the upgrade process to operate, preventing other programs such as user interaction programs from writing data during the upgrade, which could lead to damage to the application area program.
[0060] S3: Application area firmware pulse idle write. For example... Figure 5 As shown, the pulse output idle state writing technology is used to write the application area firmware into the Flash in fragments. The core is to avoid conflicts between Flash write operations and pulse interrupts by accurately calculating the pulse interval and monitoring the pulse status in real time, so as to ensure stable pulse frequency and accurate measurement.
[0061] S31: Pulse interval calculation and adaptation. For example... Figures 2-3As shown, the MCU calls the pulse frequency calculation module to calculate the minimum pulse interval time T (in seconds) based on the meter's current operating parameters: instantaneous power P and pulse constant C. The formula is "T=3600×1000 / (C×P)". The pulse constant C is an inherent parameter of the meter, commonly 20000 imp / kWh, meaning 20000 pulses are output for every 1kWh of energy consumed. The instantaneous power P is collected in real-time by the metering chip, with a sampling frequency of no less than 1Hz to ensure data real-time performance. After calculation, the MCU reads the single-block write time of the Flash chip, typically 0.03-0.08 seconds, for adaptation judgment.
[0062] (1) If T is greater than the single block write time, such as T=0.18 seconds and write time=0.05 seconds, write directly according to the standard 64KB / block fragment;
[0063] (2) If T is less than the single block write time, T is insufficient in special scenarios. The fragment size needs to be dynamically reduced to 32KB so that the single block write time is reduced to less than 0.02 seconds, ensuring that the write operation can be completed during the pulse idle period.
[0064] S32: Precise Pulse Status Monitoring. The MCU starts the pulse monitoring program, setting its interrupt priority to the highest level, higher than other interrupts such as communication and display, to prevent interference from other programs in pulse detection. The rising edge of the pulse interrupt signal output by the metering chip triggers the interrupt, determining the current status in real time.
[0065] (1) Rising edge detected: It is determined to be a "pulse output period". The MCU immediately sends a pause signal to the Flash write control module to stop all write operations and respond to the pulse interrupt first. At this time, the metering chip outputs pulses at the normal frequency and there is no delay at the software level.
[0066] (2) Falling edge detected: It is determined to be a "pulse idle period". The MCU sends a write permission signal to the Flash write control module to start the fragmented data writing and records the current writing progress, such as the 5th block and a total of 30 blocks.
[0067] S33: Fragmented Writing and Real-time Verification. During the pulse idle period, the MCU writes the application area firmware into fragments of the adapted size to the Flash application area. After each block is written, two operations are immediately performed:
[0068] (1) Local CRC check: Calculate the CRC value of the currently written block and compare it with the CRC value of the corresponding fragment in the new firmware. If they are inconsistent, erase the block and rewrite it to avoid the accumulation of erroneous data.
[0069] (2) Secondary pulse state detection: If the current period is still idle and no rising edge is detected, continue writing to the next block; if a rising edge is detected, stop writing immediately and wait for the next falling edge to trigger before resuming operation. Repeat the above process until all fragment data in the application area is written and passes verification, and the application area upgrade is completed.
[0070] S4: Post-upgrade functionality and metering stability verification. After the upgrade, the MCU performs a multi-dimensional verification process to ensure that the upper-level functions of the meter are normal, the metering accuracy meets the standards, and the long-term operation is stable, avoiding hidden faults after the upgrade.
[0071] S41: Application Area Function Full Check. The MCU starts all upper-layer functions in the application area in a preset order, verifying their operational status one by one, including:
[0072] (1) Display function: Control the LCD screen to display the current power, voltage, current, power and other parameters in a loop, and check whether the displayed content is accurate and free of garbled characters.
[0073] (2) Communication function: Send an “upgrade pending verification” signal to the remote platform through the original communication module, which includes information such as the current firmware version and hardware parameters. The signal transmission success rate must reach 100%.
[0074] (3) User interaction function: Trigger the meter buttons such as query button and reset button, check whether the button response is timely and whether the function is normal, such as the query button being able to retrieve historical electricity consumption data.
[0075] If any function malfunctions, the MCU will immediately trigger the rollback mechanism. It will switch back to the old firmware application area before the upgrade and report the "function malfunction" and the specific faulty module to the platform, making it easier for maintenance personnel to locate and handle the problem.
[0076] S42: Metering accuracy classification verification. Based on the meter's accuracy class, such as class 0.5s or class 1.0s, the MCU performs a 10-minute continuous metering verification, collecting and comparing key data, including:
[0077] (1) Cumulative power consumption deviation: Record the cumulative power consumption within 10 minutes after the upgrade and compare it with the theoretical power consumption under the same power before the upgrade (calculated by P×time). The deviation of the class 0.5s meter should not exceed 0.005kWh, and the deviation of the class 1.0s meter should not exceed 0.01kWh.
[0078] (2) Pulse output consistency: The actual number of pulse outputs within 10 minutes is counted and compared with the theoretical number of outputs calculated by C × cumulative power consumption. The deviation should not exceed 1 time.
[0079] (3) Pulse frequency stability: Real-time acquisition of pulse interval time and calculation of standard deviation must not exceed 0.001 seconds to ensure no frequency fluctuation.
[0080] If the accuracy verification fails, the MCU will switch back to the old firmware and report "measurement abnormality". The platform will then investigate and upgrade again.
[0081] S43: System Switching and Long-Term Monitoring. After both functionality and accuracy have been verified as qualified, the MCU will officially switch the system operation partition to the driver and application areas of the new firmware, and at the same time send an "upgrade successful" signal to the remote platform, including log information such as upgrade completion time, current firmware version, and measurement accuracy data.
[0082] To ensure long-term stability, the MCU initiates 24-hour sampling monitoring: collecting metering data once per hour, including cumulative electricity consumption, pulse count, and functional status (communication and display), and storing it in the local Flash log area. After 24 hours, the monitoring data is uploaded to the platform, which uses big data analysis to determine if there are any long-term operational risks in the meter, such as metering accuracy drift, in order to achieve closed-loop management of the upgrade effect.
[0083] 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 upgrading an electricity meter to maintain stable pulse frequency and metering, characterized in that, Includes the following steps: S1: Receive firmware upgrade instructions from the remote operation and maintenance platform through the built-in communication module of the electricity meter, verify the legality of the instructions, download the firmware in standard segments and enable breakpoint resume, and perform security verification on the firmware after completion. S2: Based on the partition architecture of driver area and application area, the upgrade scope is determined by partition comparison. If the driver area needs to be upgraded, the metering core program is copied to SRAM to temporarily take over the metering function. After the driver area is written, it is switched back to the new Flash driver area. S3: Calculates the minimum pulse interval based on the instantaneous power of the electricity meter and the pulse constant, adapts to the Flash single block write time, monitors the pulse status in real time, and writes the application area firmware into Flash in fragments during the pulse idle period. S4: After the upgrade, the functions and metrological stability are verified. The application area functions are fully checked and the metrological accuracy is graded and verified. After completion, the system is switched to the new firmware.
2. The meter upgrade method for maintaining pulse frequency and metering stability according to claim 1, characterized in that, Step S1 includes: S11: The meter's main control unit (MCU) parses the instructions, extracts the firmware version number, platform digital signature, and instruction issuance time, verifies the validity of the digital signature using the locally stored platform public key, checks whether the new firmware version number is higher than the current version, and checks whether the instruction issuance time exceeds the threshold from the current time. S12: Divide the external Flash storage chip into a temporary storage area and a target upgrade area, download the firmware in standard segments, record the progress after each data storage block is completed during the download process, and continue downloading from the breakpoint after network interruption is restored; S13: After all fragments have been downloaded, a verification is performed. If the verification fails, the temporary storage area is cleared and a re-download is requested. If the verification passes, the firmware fragments are transferred to the target upgrade area.
3. The method for upgrading an electricity meter to maintain pulse frequency and metering stability according to claim 1, characterized in that, Step S2 includes: S21: Compare the driver area of the previous firmware with the driver area of the new firmware, match the application area of the previous firmware with the application area of the new firmware, and distinguish between three upgrade scenarios: only upgrade the application area, prioritize upgrade the driver area, and upgrade the driver area first and then the application area. S22: Copy the core metering program in the driver area to SRAM and pass the verification. Switch the metering function execution carrier from Flash to SRAM. After the new driver area is written in slices and verified block by block, switch the metering function back to the new driver area and release SRAM. S23: Regardless of whether the driver area is upgraded, the new firmware application area is marked as "pending upgrade" and the read and write permissions of the application area are locked, allowing only the upgrade process to operate on it.
4. The meter upgrade method for maintaining pulse frequency and metering stability according to claim 1, characterized in that, Step S3 includes: S31: Calculate the minimum pulse interval time T; read the Flash single block write time. If T is greater than the write time, write according to the original block size. If T is less than the write time, reduce the fragment size. S32: Set the interrupt priority of the pulse monitoring program to the highest level, determine the "pulse output period" by the rising edge of the pulse interrupt signal of the metering chip, and send a pause signal to the Flash write control module; determine the "pulse idle period" by the falling edge, send a write permission signal and record the write progress; S33: During the pulse idle period, write the application area firmware according to the appropriate fragment size. Perform local verification after each fragment is written until all fragments are written and verified.
5. The method for upgrading an electricity meter to maintain pulse frequency and metering stability according to claim 1, characterized in that, Step S4 includes: S41: Start all upper-layer functions in the application area in a preset order, verify the display function, communication function, and user interaction function. If any function is abnormal, switch back to the old firmware and report the faulty module. S42: Perform continuous metering verification, compare the cumulative power consumption deviation, pulse output consistency, and pulse frequency stability. If the accuracy does not meet the standard, switch back to the old firmware and provide feedback. S43: After the function and accuracy verification is qualified, switch to the new firmware and send an upgrade success log to the platform; start long-term sampling monitoring, collect and store metering data and functional status every hour, and upload the data to the platform for potential hazard analysis after the monitoring ends.
6. The meter upgrade method for maintaining pulse frequency and metering stability according to claim 4, characterized in that, The formula for calculating the minimum pulse interval time T is T=3600×1000 / (C×P), where C is the meter pulse constant and P is the instantaneous power collected in real time by the metering chip.
7. The meter upgrade method for maintaining pulse frequency and metering stability according to claim 4, characterized in that, Step S33 further includes performing a second pulse state detection: if the device is still idle after writing a block, writing continues; if a rising edge is detected, writing stops.
8. The meter upgrade method for maintaining pulse frequency and metering stability according to claim 3, characterized in that, In step S21, the comparison uses the SHA256 hash algorithm.
9. The method for upgrading an electricity meter to maintain pulse frequency and metering stability according to claim 2, characterized in that, In S13, the verification includes CRC32 cyclic redundancy check and SHA256 hash check.