Method and device for dynamically setting dog feeding time of watchdog circuit
By monitoring CPU load and power consumption, and dynamically adjusting the watchdog timer, the problems of false resets and resource waste in traditional watchdog circuits under different task modes are solved, thereby improving system stability and resource utilization.
Patent Information
- Application Number
- CN202510970557.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2025-11-21
AI Technical Summary
传统看门狗电路的喂狗时间固定,无法适应系统在不同任务模式下的动态需求,导致误复位或资源浪费。
By monitoring the CPU's power consumption and load, the watchdog timer is adjusted in real time using a fitted relationship. A square wave generation circuit and optocoupler isolation technology are employed to dynamically adjust the watchdog timer to adapt to changes in system load.
This effectively avoids accidental resets and resource waste, improving system stability and resource utilization.
Smart Images

Figure CN120994432A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic communications, and more specifically, to a watchdog circuit capable of dynamically adjusting the watchdog feeding time according to the system task status. Background Technology
[0002] A watchdog timer (WDT) is a common module in embedded systems used to monitor system operation. It works by periodically receiving a "feed" signal to determine if the system is functioning correctly. If no "feed" signal is received within a specified time, a system reset is triggered.
[0003] Traditional watchdog circuits have a fixed feeding time, which cannot adapt to the dynamic needs of the system under different task modes. For example, when the system is performing a high-load task, the main program may delay feeding the watchdog, leading to false resets; while in idle states, a fixed feeding time will cause unnecessary resource consumption. Therefore, there is an urgent need for a watchdog circuit that can dynamically adjust the feeding time according to the system status. Summary of the Invention
[0004] The purpose of this invention is to address the deficiencies in the existing technology by providing a method that can dynamically adjust the watchdog timeout based on system load, thus solving the problem of false resets or resource waste caused by fixed watchdog feeding times.
[0005] To achieve the above objectives, the present invention provides a method for dynamically setting the watchdog timer feeding time, comprising the following steps:
[0006] Collect and monitor the CPU's power consumption and corresponding load, and fit the CPU load and power based on the monitoring data to reflect the system's operating status.
[0007] The CPU power consumption is monitored in real time. Based on the fitting relationship between CPU load and power, the real-time CPU load is calculated, and the watchdog timer is determined based on the CPU load.
[0008] By setting the square wave period, the timeout time of the acquired square wave is set, and this timeout time is consistent with the watchdog timer feeding time determined according to the CPU load.
[0009] This invention fits CPU power consumption and load, monitors CPU load in real time, adjusts the square wave period, and dynamically adjusts the watchdog timeout based on CPU load, thus avoiding resource waste.
[0010] Furthermore, the square wave period is adjusted via a square wave generation circuit. This circuit includes a 555 timer U3, a resistor R4, a capacitor C1, a programmable resistor R3, and a counter U4. The programmable resistor R3 and resistor R4 are connected in parallel to the 555 timer U3, and resistor R4 and capacitor C1 are also connected in parallel to the 555 timer U3. The output of the 555 timer is connected to the counter U4. The method for adjusting the square wave period is as follows:
[0011] Formula for calculating the high level of a square wave:
[0012] t1 = 0.693*(R3+R4)*C1,
[0013] Formula for calculating the low level of a square wave:
[0014] t2 = 0.693 * R4 * C1,
[0015] Duty cycle calculation formula:
[0016]
[0017] In the formula, t1 represents the time of the square wave high level, t2 represents the time of the square wave low level, C1 represents the capacitance value of capacitor C1, R3 represents the resistance value of programmable resistor R3, R4 represents the resistance value of resistor R4, and D represents the square wave duty cycle.
[0018] In some embodiments, as a preferred method, the watchdog timer is determined based on the CPU load using the following specific method: when the CPU load is 0%–20%, the watchdog timer is set to 100ms–300ms; when the CPU load is 20%–40%, the watchdog timer is set to 300ms–500ms; when the CPU load is 40%–60%, the watchdog timer is set to 500ms–1s; when the CPU load is 60%–80%, the watchdog timer is set to 1s–2s; and when the CPU load is 80%–100%, the watchdog timer is set to 2s or more.
[0019] Furthermore, the above dynamic setting method also includes resetting the system and electrically isolating the output for setting the dog-feeding time and the system reset input through optocoupler isolation.
[0020] The present invention also provides a device for dynamically setting the watchdog circuit feeding time, comprising:
[0021] The system status monitoring module collects and monitors CPU power consumption in real time;
[0022] The MCU unit fits the CPU load and power consumption based on the monitored historical data, calculates the CPU load based on the real-time collected CPU power consumption, and adjusts the timing parameters of the time-adjustable timer module according to the CPU load.
[0023] The time-adjustable timer module uses a square wave generation circuit. The square wave generation circuit includes a 555 timer, a programmable resistor, and a counter circuit. The resistance value of the programmable resistor is adjusted by the MCU unit to set the square wave period. The counter circuit collects the square wave and sets the timeout time.
[0024] This invention utilizes the MCU unit to dynamically adjust the watchdog timer threshold based on the input frequency of the adjustable timer module controlled by the system load. When the system is under high load, the CPU shortens the watchdog timer interval to avoid system reset due to task delays; when the system is idle or under low load, the CPU extends the watchdog timer interval, reducing the frequency of watchdog timer operations, thereby improving system stability and resource utilization.
[0025] Furthermore, the aforementioned dynamic setting device also includes a reset circuit, which employs optocoupler isolation to electrically isolate the output of the time-adjustable timer module from the system reset input.
[0026] In some embodiments, as a preferred embodiment, the square wave generating circuit includes a 555 timer U3, a resistor R4, a capacitor C1, a programmable resistor R3, and a counter U4; the programmable resistor R3 and the resistor R4 are connected in parallel to the 555 timer U3, and the resistor R4 and the capacitor C1 are connected in parallel to the 555 timer U3; the output terminal of the 555 timer is connected to the counter U4.
[0027] The system status monitoring module uses a current acquisition circuit connected in series with the main CPU's power supply circuit, and the MCU unit monitors the CPU's power consumption in real time through ADC acquisition.
[0028] The present invention has the following advantages over the prior art:
[0029] Traditional watchdog circuits have a fixed feeding time, which cannot adapt to the dynamic needs of the system under different task modes. This invention utilizes the relationship between CPU load and power consumption to dynamically adjust the timer time online to adapt to different systems, reduce the feeding cycle and CPU resource utilization.
[0030] This invention has a simple structure and solves the problem of accidental reset or resource waste caused by fixed dog feeding time. It is applicable to embedded systems, industrial control and other fields. Attached Figure Description
[0031] Figure 1 This is a structural block diagram of the watchdog circuit's dynamic setting device for the watchdog feeding time according to the present invention;
[0032] Figure 2 for Figure 1 Schematic diagram of the current acquisition circuit in the system status monitoring module;
[0033] Figure 3 for Figure 1 Schematic diagram of a medium-time adjustable timer module;
[0034] Figure 4 for Figure 1 Schematic diagram of the reset circuit;
[0035] Figure 5 This is a flowchart illustrating the dynamic setting method for the watchdog circuit feeding time according to the present invention. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention without creative effort are within the scope of protection of the present invention. Unless otherwise defined, the technical or scientific terms used herein should have the ordinary meaning understood by those skilled in the art.
[0037] The terms "first," "second," and similar words used in this invention application specification and claims do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, unless the context clearly indicates otherwise, the singular forms of "an," "a," or "the," etc., do not indicate a quantity limitation, but rather indicate the presence of at least one. Terms such as "comprising" or "including" indicate that the element or object preceding "comprising" encompasses the features, integrals, steps, operations, elements, and / or components listed following "comprising" or "including," and do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or sets thereof. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0038] This invention provides a method for dynamically setting the feeding time of a watchdog circuit. To make the objectives, technical solutions, and effects of this invention clearer and more explicit, the invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only for explaining the invention and are not intended to limit the invention.
[0039] like Figure 1 The diagram shows the overall structure of a watchdog circuit for dynamically setting the feeding time, which mainly includes a system status monitoring module, an MCU unit, a time-adjustable timer module, and a reset circuit.
[0040] like Figure 2 As shown, the system status monitoring module uses a current acquisition circuit connected in series with the power supply circuit of the main CPU. The MCU unit collects and monitors the CPU power consumption in real time through ADC, and through multiple tests, fits a binary function y = ax + b of CPU load and power consumption to reflect the operating status of the system.
[0041] This embodiment uses the Loongson CPU as an example to fit the CPU load and power consumption. The fitting results are as follows:
[0042] y = 9x + 0.8
[0043] In the formula, y represents the CPU power consumption in watts (W); x represents the CPU load in percentiles (%).
[0044] The MCU unit is used to collect system power consumption and adjust timer timing parameters in real time, i.e., to control the programmable potentiometer.
[0045] like Figure 3 The diagram shows an adjustable timer module that uses a square wave generation circuit. This circuit includes a 555 timer U3, resistor R4, a programmable resistor R3, and a counter U4. The connection point between programmable resistor R3 and resistor R4 is connected to pin 7 of the 555 timer U3. The connection point between resistor R4 and capacitor C1 is then connected to pins 2 and 6 of the 555 timer U3. Pin 3 of the 555 timer is connected to pin 1 of the subsequent counter U4. Pin 2 of counter U4 is connected to the system's watchdog signal, and pin 3 is connected to the subsequent reset circuit. The MCU unit adjusts the resistance value of programmable resistor R3 via the IIC interface to set the square wave period. Counter U4 is used to acquire the square wave, set the timeout period, and output the result to the system's watchdog signal.
[0046] Formula for calculating the high level of a square wave:
[0047] t1 = 0.693*(R3+R4)*C1,
[0048] Formula for calculating the low level of a square wave:
[0049] t2 = 0.693 * R4 * C1,
[0050] Duty cycle calculation formula:
[0051]
[0052] In the formula, t1 represents the time of the square wave high level, t2 represents the time of the square wave low level, C1 represents the capacitance value of capacitor C1, R3 represents the resistance value of programmable resistor R3, R4 represents the resistance value of resistor R4, and D represents the square wave duty cycle.
[0053] The timeout setting for the watchdog circuit can be adjusted based on different system requirements and real-time CPU load. This embodiment uses the following reference setting:
[0054] Table 1. Adjustment Range for Dog Feeding Time
[0055] Serial Number CPU load range Feeding time range 1 0%~20% 100ms~300ms 2 20~40% 300ms~500ms 3 40~60% 500ms~1s 4 60~80% 1s~2s 5 80~100% 2s and above
[0056] like Figure 4 The circuit shown employs optocoupler isolation to electrically isolate the output of the time-adjustable timer module from the system reset input, ensuring the stability of the reset signal and enabling the entire system to be reset.
[0057] like Figure 5 As shown, this invention dynamically sets the watchdog timer feeding time. The system power consumption is monitored in real time by the MCU unit. The real-time CPU load is calculated by using the fitting relationship between CPU load and power consumption. The CPU load is compared with the watchdog timer feeding time, and the watchdog feeding frequency is adjusted with reference to Table 1.
[0058] While the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the invention. Those skilled in the art can make various modifications and refinements without departing from the spirit and scope of the invention. Therefore, the scope of protection of the present invention shall be determined by the claims.
Claims
1. A method for dynamically setting the watchdog timer feeding time in a watchdog circuit, characterized in that, Includes the following steps: Collect and monitor the CPU's power consumption and corresponding load, and fit the CPU load and power based on the monitoring data to reflect the system's operating status. The CPU power consumption is monitored in real time. Based on the fitting relationship between CPU load and power, the real-time CPU load is calculated, and the watchdog timer is determined based on the CPU load. By setting the square wave period, the timeout time of the acquired square wave is set, and this timeout time is consistent with the watchdog timer feeding time determined according to the CPU load.
2. The dynamic setting method according to claim 1, characterized in that, The square wave period is adjusted by a square wave generating circuit. This circuit includes a 555 timer U3, a resistor R4, a capacitor C1, a programmable resistor R3, and a counter U4. The programmable resistor R3 and resistor R4 are connected in parallel to the 555 timer U3, and resistor R4 and capacitor C1 are also connected in parallel to the 555 timer U3. The output of the 555 timer is connected to the counter U4. The square wave period is set by adjusting the resistance value of the programmable resistor R3. The method for adjusting the square wave period is as follows: Formula for calculating the high level of a square wave: t1 = 0.693*(R3+R4)*C1, Formula for calculating the low level of a square wave: t2 = 0.693 * R4 * C1, Duty cycle calculation formula: In the formula, t1 represents the time of the square wave high level, t2 represents the time of the square wave low level, C1 represents the capacitance value of capacitor C1, R3 represents the resistance value of programmable resistor R3, R4 represents the resistance value of resistor R4, and D represents the square wave duty cycle.
3. The dynamic setting method according to claim 2, characterized in that, The specific method for determining the watchdog timer based on CPU load is as follows: when the CPU load is 0%–20%, the watchdog timer is set to 100ms–300ms; when the CPU load is 20%–40%, the watchdog timer is set to 300ms–500ms; when the CPU load is 40%–60%, the watchdog timer is set to 500ms–1s; when the CPU load is 60%–80%, the watchdog timer is set to 1s–2s; and when the CPU load is 80%–100%, the watchdog timer is set to 2s or more.
4. The dynamic setting method according to claim 1, characterized in that, The dynamic setting method also includes resetting the system and electrically isolating the output for setting the dog feeding time and the system reset input through optocoupler isolation.
5. A dynamic setting device for watchdog circuit feeding time, characterized in that, include: The system status monitoring module collects and monitors CPU power consumption in real time; The MCU unit fits the CPU load and power consumption based on the monitored historical data, calculates the CPU load based on the real-time collected CPU power consumption, and adjusts the timing parameters of the time-adjustable timer module according to the CPU load. The time-adjustable timer module uses a square wave generation circuit. The square wave generation circuit includes a 555 timer, a programmable resistor, and a counter circuit. The resistance value of the programmable resistor is adjusted by the MCU unit to set the square wave period. The counter circuit collects the square wave and sets the timeout time.
6. The dynamic setting device according to claim 5, characterized in that, The dynamic setting device also includes a reset circuit, which uses optocoupler isolation to electrically isolate the output of the time-adjustable timer module from the system reset input.
7. The dynamic setting device according to claim 5, characterized in that, The square wave generating circuit includes a 555 timer U3, a resistor R4, a capacitor C1, a programmable resistor R3, and a counter U4; the programmable resistor R3 and the resistor R4 are connected in parallel to the 555 timer U3, and the resistor R4 and the capacitor C1 are connected in parallel to the 555 timer U3; the output terminal of the 555 timer is connected to the counter U4.
8. The dynamic setting device according to claim 5, characterized in that, The system status monitoring module uses a current acquisition circuit connected in series with the main CPU's power supply circuit, and the MCU unit monitors the CPU's power consumption in real time through ADC acquisition.
Citation Information
Cited By
Watchdog low-power-consumption control method, device and equipment
CN121957919A
A watchdog low-power control method, device and equipment
CN121957919B