Electric energy meter and system crash recovery method

By introducing a dual watchdog mechanism into the power meter system, the cyclic feeding dog and timer record the business running time, the crash reset problem caused by a single watchdog circuit is solved, ensuring the stable operation and metering function of the power meter system.

CN119311444APending Publication Date: 2025-01-14HENAN XJ INSTR +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411122599.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-15
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

When the existing crash recovery is performed through a single watchdog circuit, the long interruption of service time leads to automatic reset of the system, which affects the normal operation and metering function of the power meter.

Method used

The first watchdog and the second watchdog are set in the system, and the cyclic feeding operation is performed in a service with a long execution cycle, and the service running time is recorded using the timer of the second watchdog. If the setting is exceeded, the setting is System reset is performed on a fixed cycle to avoid automatic reset problems caused by not feeding dogs for a long time.

Benefits of technology

Through the combination of the first watchdog and the second watchdog, the crash and automatic reset are prevented, ensuring that the power meter system can return to normal operation in the event of crash, and avoid metering abnormalities and power disputes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311444A_ABST
    Figure CN119311444A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of computer error correction, and particularly relates to an electric energy meter and a system crash recovery method. The method comprises the following steps: setting a first watchdog and a second watchdog in a system, performing dog feeding operation on the first watchdog and initializing a timer of the second watchdog every time the system runs a main cycle; when running in a single service with a relatively long execution period, carrying out circulating dog feeding operation on the first watchdog according to a first timing period, and recording service running time by utilizing a timer of the second watchdog; when the first watchdog does not receive dog feeding in the first timing period, system resetting is carried out; if yes, whether the time recorded by the second watchdog timer is larger than the second timing period or not is further judged, and if yes, system resetting is carried out; the second timing period is determined according to the operation time of the service, and the second timing period is longer than the first timing period, so that the problem that the system is automatically reset if the service interruption time is relatively long during crash recovery in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of computer error correction, and in particular relates to an electric energy meter and a system crash recovery method. Background Art

[0002] System crash means that the program pointer of the CPU enters an infinite loop and cannot execute the normal program flow. The current common crash recovery method is to introduce a single watchdog circuit and feed the watchdog periodically in the main loop of the system. When the system crashes, the main loop task is no longer executed, and the system cannot feed the watchdog. The watchdog circuit does not receive the watchdog feed within the set time period, causing the watchdog overflow interrupt, and the automatic control system is reset, thereby solving the system crash problem. The energy meter is an important part of the power system. As an electricity metering device at the metering point of the power system, its function is to convert electric energy into readable electric energy data and provide it to users or power companies for metering and settlement. It is of great significance to ensure fair and reasonable metering of electric energy consumption. However, with the development needs of new power systems, new scenarios and new businesses of electricity consumption continue to increase, and more and more functional expansion requirements are put forward for electric energy meters with massive users, such as harmonic measurement, power quality analysis, user load identification, and a large number of high-speed data interaction requirements, etc., resulting in the continuous increase in the design complexity of the software and hardware systems of the electric energy meter, which brings great challenges to the design reliability of the electric energy meter. Especially in the complex electromagnetic environment and various application scenarios of different users, the reliability of the on-site operation of the energy meter is crucial. Major problems such as the energy meter crash must not occur. Otherwise, it will affect the success rate of power system data collection and assessment indicators at the very least, and directly affect the metering function of the energy meter, resulting in abnormal energy metering and causing electricity disputes.

[0003] The symptoms of an energy meter crash include non-accumulation of energy metering, communication failure, loss of the freeze function, no response to buttons, and frozen display. The cause of the crash is related to the energy meter hardware and software systems. When a single watchdog circuit is used to solve the energy meter system crash caused by hardware or software problems, as the business processed by the smart energy meter becomes more and more complex, when the time required for the processed business is longer than the watchdog feeding cycle, the energy meter software system processes a single business for a long time and cannot enter the main loop task. Due to the characteristics of the watchdog circuit, if the watchdog is not fed within a certain feeding cycle, it will automatically trigger a system reset, affecting the execution of the entire system business of the energy meter. Summary of the invention

[0004] The object of the present invention is to provide an electric energy meter and a system crash recovery method, so as to solve the problem of automatic system reset caused by long service interruption time when crash recovery is performed through a single watchdog circuit.

[0005] In order to solve the above technical problems, the present invention provides a system crash recovery method, comprising: The first watchdog and the second watchdog are set in the system. Each time the system runs the main loop, the first watchdog is fed and the second watchdog timer is initialized. When running in a single service with a long execution cycle, a cyclic dog feeding operation is performed on the first watchdog according to the first timing cycle in the service, and the timer of the second watchdog is used to record the running time of the service; When the first watchdog does not receive a feeding signal within the first timing cycle, the system is reset; if it is received, it is further determined whether the service running time recorded by the second watchdog timer is greater than the second timing cycle. If so, the system is reset; the second timing cycle is determined based on the service running time, and the second timing cycle is greater than the first timing cycle.

[0006] Furthermore, the initialization refers to clearing a timer, and the timer records the service running time by accumulation. If the timing value of the second watchdog timer is greater than the second timing period after accumulation, the system is reset. Furthermore, the initialization refers to assigning a value to the timer as a second timing cycle, and the timer records the service running time by cumulative reduction. If the timing value of the second watchdog timer is equal to zero after the cumulative reduction, the system is reset.

[0007] Furthermore, the first watchdog is a hardware watchdog, and the second watchdog is a software simulated watchdog.

[0008] Furthermore, the command for resetting the system when the first watchdog does not receive a dog feeding signal within the first timing cycle is a hardware reset, and the command for resetting the system when the service running time recorded by the second watchdog timer is greater than the second timing cycle is a software reset.

[0009] The beneficial effects of the above technical solution are as follows: the present invention is an improved invention creation, in addition to feeding the first watchdog each time the main loop is run, the first watchdog is also cyclically fed in a single business with a long execution cycle, thereby not only preventing the problem of a deadlock caused by the main loop of the hardware or software system entering a dead loop, but also avoiding the problem of automatic system reset caused by the long-term failure to feed the first watchdog when the business time is long, and in order to avoid a new deadlock problem caused by cyclic feeding of the first watchdog in the business when an abnormality occurs and the business cannot be exited, the present invention introduces a second watchdog. Watchdog, each time the main loop runs once, the second watchdog timer is initialized. When running in a single business, the second watchdog timer is used to record the business running time. If the recorded time is greater than the set second timing cycle, the business operation is judged to have timed out. At this time, the system is reset to restore the system from such a freeze. The first watchdog and the second watchdog are used in conjunction with each other. The first watchdog serves as the first line of defense for freeze recovery. When the first watchdog is invalid, the second watchdog serves as the second line of defense for freeze recovery, and performs final recovery and remedy on the system to bring the system back to normal operating state.

[0010] In order to solve the above technical problems, the present invention further provides an electric energy meter, including an electric energy meter software system, in which a first watchdog and a second watchdog are set, and each time the electric energy meter software system runs a main loop, the first watchdog is fed and the second watchdog timer is initialized; When running in a single service with a long execution cycle, a cyclic dog feeding operation is performed on the first watchdog according to the first timing cycle in the service, and the timer of the second watchdog is used to record the running time of the service; When the first watchdog does not receive a feeding signal within the first timing cycle, the electric energy meter is reset; if it is received, it is further determined whether the service running time recorded by the second watchdog timer is greater than the second timing cycle. If so, the electric energy meter is reset; the second timing cycle is determined according to the service running time, and the second timing cycle is greater than the first timing cycle.

[0011] Furthermore, the initialization refers to clearing a timer, and the timer records the service running time by accumulation. If the timing value of the second watchdog timer is greater than the second timing period after accumulation, the system is reset.

[0012] Furthermore, the initialization refers to assigning a value to the timer as a second timing cycle, and the timer records the service running time by cumulative reduction. If the timing value of the second watchdog timer is equal to zero after the cumulative reduction, the system is reset.

[0013] Furthermore, the first watchdog is a hardware watchdog, and the second watchdog is a software simulated watchdog.

[0014] Furthermore, the command for resetting the system when the first watchdog does not receive a dog feeding signal within the first timing cycle is a hardware reset, and the command for resetting the system when the service running time recorded by the second watchdog timer is greater than the second timing cycle is a software reset.

[0015] The beneficial effects of the above technical solution are as follows: the present invention is an improved invention creation. In the electric energy meter software system, in addition to feeding the first watchdog each time the main loop is run, the first watchdog is also cyclically fed in a single business with a long execution cycle, thereby not only preventing the problem of a deadlock that cannot be recovered due to the main loop of the hardware or software system entering a dead loop, but also avoiding the problem of automatic system reset due to long-term failure to feed the first watchdog when the business time is long. In order to avoid a new deadlock caused by cyclic feeding of the first watchdog in the business when an abnormality occurs and the business cannot be exited, the present invention introduces a second watchdog. The second watchdog timer is initialized each time the main loop is run. When running in a single business, the second watchdog timer is used to record the business running time. If the recorded time is greater than the set second timing cycle, the business operation is judged to have timed out. At this time, the system is reset to restore the electric energy meter system from such a freeze. The first watchdog and the second watchdog are used in conjunction with each other. The first watchdog serves as the first line of defense for freeze recovery. When the first watchdog is invalid, the second watchdog serves as the second line of defense for freeze recovery, and performs final recovery and remedy on the electric energy meter system, bringing the electric energy meter system back to normal operating state. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a main cycle business flow chart of an electric energy meter embodiment of the present invention; Figure 2 It is a business internal loop diagram with a relatively long single execution cycle in an embodiment of an electric energy meter of the present invention; Figure 3 This is an execution flow chart of the second watchdog of the electric energy meter embodiment of the present invention when executing a business with a longer cycle. DETAILED DESCRIPTION

[0017] In order to make the purpose, technical solutions and advantages of the present invention more clear, the specific implementation methods of the present invention are further described below in conjunction with the accompanying drawings.

[0018] The present invention adopts a dual watchdog mode. In addition to feeding the first watchdog each time the main loop is run, the first watchdog is also cyclically fed in a single service with a long execution cycle. This not only prevents the problem of a deadlock that cannot be recovered due to the main loop of the hardware or software system entering a dead loop, but also avoids the problem of automatic system reset caused by not feeding the main loop for a long time when the service time is long. In order to avoid a new deadlock caused by cyclic feeding of the first watchdog in the service when an abnormality occurs and the service cannot be exited, the present invention introduces a second watchdog. Each time the main loop is run, the second watchdog is fed. The second watchdog timer is initialized. When running in a single long-cycle execution business, the second watchdog timer is used to record the business running time. If the recorded time is greater than the set second timing cycle, the business operation is judged to have timed out. At this time, the system is reset to restore the system from such a freeze. The first watchdog and the second watchdog are used in conjunction with each other. The first watchdog serves as the first line of defense for freeze recovery. When the first watchdog is invalid, the second watchdog serves as the second line of defense for freeze recovery, and performs a final recovery and remedy on the system to bring the system back to normal operating state.

[0019] Electricity meter embodiment The present invention provides an electric energy meter, which includes an electric energy meter system, wherein the electric energy meter system includes an electric energy meter software system and a hardware system, and the electric energy meter system is provided with a first watchdog and a second watchdog, wherein the first watchdog is a hardware watchdog, serving as a main watchdog; and the second watchdog is a software simulated watchdog, serving as a guard watchdog. The first watchdog is used to solve the problem that the system crashes and cannot be recovered due to hardware problems or the main loop of the software entering a dead loop, and at the same time solves the problem that the system is reset due to a certain business running for too long, exceeding the first timing cycle of the first watchdog. Businesses with longer execution cycles include interrupt services and small loop branch services in the main loop, and longer means that the running time is greater than the first timing cycle. The second watchdog is used to prevent a crash that may occur in a business with a longer execution cycle due to the feeding of the first watchdog cycle. According to the above settings, the electric energy meter recovers the electric energy meter software system from the crash through a system crash recovery method, and pulls the electric energy meter system back to normal operating state. The implementation principle of the system crash recovery method is as follows: Figure 1-3 As shown, the detailed description is given below.

[0020] The electric energy meter software system feeds the first watchdog and initializes the second watchdog timer each time the main loop is run once. When the system is running in a single service with a long execution time, the first watchdog is cyclically fed according to the first timing cycle T1 in the service, and the timer of the second watchdog is used to record the running time of the service with a long execution cycle. When the first watchdog does not receive the feeding signal within the first timing cycle, the electric energy meter is reset. If the first watchdog receives the feeding signal, it further determines whether the running time of the service recorded by the second watchdog timer is greater than the second timing cycle. If so, the electric energy meter is reset. The second timing cycle T2 is determined according to the running time of the service with a long execution cycle. T2 is generally set to be slightly greater than the running time of the service with a long execution cycle. For example, if the normal running time of the service with a long execution cycle is 60 seconds, T2 can be set to 61 seconds. In order to play a guarding role, the second timing cycle is greater than the first timing cycle. In order to achieve a better guarding effect, the value of T2 can be 10 times or more than 10 times of T1, for example, T1 is 6 seconds and T2 is 60 seconds.

[0021] In one embodiment, initialization refers to clearing the timer, and the timer records the service running time of the longer execution cycle by cumulative means. If the timing value of the second watchdog timer is greater than the second timing cycle after the cumulative value is greater than the second timing cycle, the system is reset. In another embodiment, initialization refers to assigning the timer to the second timing cycle, and the timer records the service running time of the longer execution cycle by cumulative means. If the timing value of the second watchdog timer is equal to zero after the cumulative value is less than the second timing cycle, the system is reset. Furthermore, the command to reset the system when the first watchdog does not receive the dog feeding within the first timing cycle is a hardware reset, and the command to reset the system when the time recorded by the second watchdog timer is greater than the second timing cycle is a software reset.

[0022] In the above method, the first watchdog is fed at two locations in the electric energy meter software system: first, in the main loop business process of the electric energy meter software system, each time the main loop is run, a dog feeding operation needs to be performed, such as Figure 1 As shown; second, in a business with a long running time and a long single execution cycle, in order to avoid system reset caused by not feeding the dog for too long, it is necessary to perform a cyclic feeding operation according to the first timing cycle in the business, such as Figure 2As shown. As an implementation method, an interrupt service refers to a service that needs to be processed in a loop. In this service, a software exception may cause the service to enter an infinite loop. At this time, the interrupt service that cannot be exited from the loop processing. Because the time required for the task to be processed is longer than the reset time of the watchdog, the first watchdog will be fed in a loop in the interrupt service. At this time, the first watchdog will determine that the system is running normally. At this time, the program pointer will always be in the interrupt service, thereby introducing a new freeze phenomenon. For this reason, the present invention introduces a second watchdog in the smart electric energy meter software system. The second watchdog needs to be operated in two locations in the software system: one is in the main loop business process of the electric energy meter software system. Each time the main loop is run, a timer initialization operation (such as clearing) is performed. Figure 1 As shown; second, in the timing interrupt service, the second watchdog timer is accumulated, and after the accumulation, it is determined whether the accumulated timing value is greater than the preset second timing cycle. If it is greater than the second timing cycle, it means that the second watchdog timer is not cleared, the interrupt service operation has timed out, the main loop has not been run for a long time, and there is a deadlock phenomenon. At this time, a forced reset of the software is performed to reset and restart the electric energy meter system; if it is less than the preset cycle, there is no need to perform a software reset, such as Figure 3 shown.

[0023] Through the cooperation of the first watchdog and the second watchdog, the timing cycle of the second watchdog is much larger than the timing cycle of the first watchdog. The first watchdog, as the first line of defense for crash recovery, solves the crash of the electric energy meter system caused by hardware problems or the software main loop entering a dead loop, and the problem of automatically triggering a system reset in a business task with a long execution cycle affecting the execution of the electric energy meter system interrupting the business. In addition, in order to prevent the internal abnormality of a long business and the failure to enter the main loop for a long time due to exceeding the business execution time, but the first watchdog is fed cyclically in the business, resulting in the failure of the first watchdog crash recovery, the second watchdog is set as the second line of defense for crash recovery, and the electric energy meter system is finally recovered and remedied to bring the electric energy meter system back to normal operation.

[0024] Method Embodiment The present invention provides a system crash recovery method, and the specific implementation process of the method has been described in detail in the electric energy meter embodiment, which will not be repeated here.

Claims

1. A method for recovering from a system crash, characterized in that: include: The first watchdog and the second watchdog are set in the system. Each time the system runs the main loop, the first watchdog is fed and the second watchdog timer is initialized. When running in a single service with a long execution cycle, a cyclic dog feeding operation is performed on the first watchdog according to the first timing cycle in the service, and the timer of the second watchdog is used to record the running time of the service; When the first watchdog does not receive a feeding signal within the first timing cycle, the system is reset; if it is received, it is further determined whether the service running time recorded by the second watchdog timer is greater than the second timing cycle. If so, the system is reset; the second timing cycle is determined based on the service running time, and the second timing cycle is greater than the first timing cycle.

2. The system crash recovery method according to claim 1, characterized in that: The initialization refers to clearing the timer, and the timer records the service running time by accumulation. If the timing value of the second watchdog timer is greater than the second timing period after accumulation, the system is reset.

3. The system crash recovery method according to claim 1, characterized in that: The initialization refers to assigning a value to the timer as the second timing cycle, and the timer records the service running time by cumulative reduction. If the timing value of the second watchdog timer is equal to zero after the cumulative reduction, the system is reset.

4. The system crash recovery method according to any one of claims 1 to 3, characterized in that: The first watchdog is a hardware watchdog, and the second watchdog is a software simulated watchdog.

5. The system crash recovery method according to claim 4, characterized in that: The command for resetting the system when the first watchdog does not receive the dog feeding within the first timing cycle is a hardware reset, and the command for resetting the system when the service running time recorded by the second watchdog timer is greater than the second timing cycle is a software reset.

6. An electric energy meter, comprising an electric energy meter software system, characterized in that: A first watchdog and a second watchdog are set in the electric energy meter software system. Each time the electric energy meter software system runs a main loop, the first watchdog is fed and the second watchdog timer is initialized. When running in a single service with a long execution cycle, a cyclic dog feeding operation is performed on the first watchdog according to the first timing cycle in the service, and the timer of the second watchdog is used to record the running time of the service; When the first watchdog does not receive a feeding signal within the first timing cycle, the electric energy meter is reset; if it is received, it is further determined whether the service running time recorded by the second watchdog timer is greater than the second timing cycle. If so, the electric energy meter is reset; the second timing cycle is determined according to the service running time, and the second timing cycle is greater than the first timing cycle.

7. The electric energy meter according to claim 6, characterized in that: The initialization refers to clearing the timer, and the timer records the service running time by accumulation. If the timing value of the second watchdog timer is greater than the second timing period after accumulation, the system is reset.

8. The electric energy meter according to claim 6, characterized in that: The initialization refers to assigning a value to the timer as the second timing cycle, and the timer records the service running time by cumulative reduction. If the timing value of the second watchdog timer is equal to zero after the cumulative reduction, the system is reset.

9. The electric energy meter according to any one of claims 6 to 8, characterized in that: The first watchdog is a hardware watchdog, and the second watchdog is a software simulated watchdog.

10. The electric energy meter according to claim 9, characterized in that: The command for resetting the system when the first watchdog does not receive the dog feeding within the first timing cycle is a hardware reset, and the command for resetting the system when the service running time recorded by the second watchdog timer is greater than the second timing cycle is a software reset.