Watchdog is divided into hardware watchdog and software watchdog. The hardware watchdog uses a timer circuit whose timing output is connected to the reset terminal of the circuit. The program clears the timer within a certain period of time (commonly known as "feeding the dog"), so when the program works normally, the timer can never Overflow, the reset signal cannot be generated. If the program fails and the watchdog is not reset in the timing period, the watchdog timer will overflow to generate a reset signal and restart the system. The software watchdog is the same in principle, except that the timer on the hardware circuit is replaced with the internal timer of the processor, which can simplify the design of the hardware circuit, but it is not as reliable as the hardware timer. For example, if the internal timer of the system fails. Unable to detect. Of course, there is also mutual monitoring through dual timers, which not only increases system overhead, but also cannot solve all problems, such as interrupting system failures causing timer interrupts to fail.
The watchdog itself is not used to solve the problems of the system. The faults found in the debugging process should be checked and corrected for the errors of the design itself. The purpose of adding the watchdog is to cause the system to crash due to factors such as potential program errors and harsh environment interference, and to automatically restore the normal working state of the system without human intervention. The watchdog cannot completely avoid the loss caused by the fault. After all, the time from the discovery of the fault to the system reset to normal is slow. At the same time, some systems also need to protect field data before resetting, and restore field data after restarting, which may also require a software and hardware overhead.
Figure 1: (a) Schematic diagram of multitasking system watchdog; (b) Corresponding watchdog reset logic diagram
The working principle of the watchdog in a single-task system is as described above and is easy to implement. The situation is slightly more complicated in a multitasking system. If each task is done like a single-task system, as shown in Figure 1(a), as long as one task works normally and "feeds the dog" regularly, the watchdog timer will not overflow. Unless all tasks fail, the watchdog timer will overflow and reset, as shown in Figure 1(b).
What we often need is that as long as there is a task failure, the system requires a reset. Or select several key tasks to be monitored, as long as one task has a problem, the system requires reset, as shown in Figure 2(a), and the corresponding watchdog reset logic is shown in Figure 2(b).
In the multi-tasking system, by creating a monitoring task TaskMonitor, its priority is higher than the task group Task1, Task2...Taskn being monitored. TaskMonitor clears the hardware watchdog timer within a certain period of time when Task1~Taskn work normally. If a Task_x of the monitored task group fails, TaskMonitor will not clear the watchdog timer, which means that the system will automatically restart when the monitored task fails. In addition, when the task TaskMonitor fails, the watchdog timer cannot be cleared in time, and the watchdog can automatically reset and restart. The next issue that needs to be solved is how to effectively monitor the task group being monitored.
Figure 2: (a) Schematic diagram of multitasking system watchdog; (b) Correct logic diagram of watchdog reset
Define a group of structures in TaskMonitor to simulate the watchdog timer group,
typedef struct
{
UINT32 CurCnt, LastCnt;
BOOL RunState;
int taskID;
} STRUCT_WATCH_DOG;
This structure includes the task ID to be monitored, which is used to simulate the variables CurCnt and LastCnt of "feeding the dog" (see below for specific meaning). The watchdog state flag RunState is used to control whether the current task is monitored.
The monitored task Task1~Taskn calls the custom function CreateWatchDog(int taskid) to create the watchdog. The monitored task requires "feeding the dog" for a period of time, and calls ResetWatchDog(int taskid). This "feeding the dog" action is essentially correct The variable CurCnt in the watchdog timer structure increases by 1. TaskMonitor is in the delayed state most of the time. Assuming that the hardware watchdog timer is 2 seconds, the monitoring task can be delayed for 1.5 seconds, and then check the created watchdog timer group one by one, and save the current value of CurCnt to LastCnt, after the delay, compare whether CurCnt and LastCnt are equal, the system is normal if they are not equal. It should be noted that the number of data bytes of CurCnt and LastCnt is too small, and "feeding the dog" is too frequent, it may happen that CurCnt plus 1 operation reaches a cycle and is equal to LastCnt.
If there is any set of CurCnt equal to LastCnt, it is considered that the task under monitoring has no "feeding dog" action, and it is detected that the task has failed and needs to be restarted. At this time, TaskMonitor does not clear the hardware watchdog timer or delay A long time, such as 10 seconds, is enough to restart the system. On the contrary, if the system is normal, Task1~Taskn periodically "feed the dog" to TaskMonitor, and TaskMonitor periodically "feeds the dog" to the hardware watchdog, the system cannot be reset. Another point is that the monitored task can cancel the corresponding watchdog by calling PauseWatchDog(int taskid), which is actually the RunState operation in the STRUCT_WATCH_DOG structure. This flag reflects the validity of the watchdog.
The maximum number of tasks that can be monitored in this way is determined by the number of STRUCT_WATCH_DOG structure data. There should be a variable in the program to record the number of watchdogs currently created. To judge whether the monitored task Task1~Taskn "feed the dog", you only need to compare the values ​​of CurCnt and LastCnt n times.
Figure 3: System reset logic diagram.
The hardware watchdog monitors the TaskMonitor task, and the TaskMonitor task monitors other monitored tasks Task1~Taskn, forming such a chain. The fault diagram of this system is shown in Figure 3. The monitored tasks Task1~Taskn and TaskMonitor are all in an OR relationship, so if any of the monitored tasks fails, the hardware circuit watchdog can be reset.
In order to realize the watchdog monitoring function of the multi-task system, a TaskMonitor task is added. How much execution time this task takes up is also an important issue. Assuming that a monitoring cycle of the TaskMonitor task is delayed by 1.5 seconds, in addition, it needs to execute statements such as saving the current count value and judging whether to "feed the dog", and its CPU usage time is very small. A specific test confirmed that using a CPU (S3C4510) with a working frequency of 50M, transplanting the vxWorks operating system, and monitoring 10 tasks with the cache disabled, each monitoring cycle takes 220 to 240 microseconds. It can be seen that the task is in the task delay state most of the time.
The monitored task may have statements such as acquiring a message, waiting for a semaphore, etc., and often the waiting for this message or semaphore is indefinite waiting. This requires some modifications to such statements. For example, in vxWorks, an indefinite acquisition of semaphore operation
semTake(semID, WAIT_FOREVER); // WAIT_FOREVER is waiting for infinite time
Decomposed into
do
{
ResetWatchDog; // "feed the dog" operation
}while(semTake(semID, sysClkRateGet( )) != OK); // wait for semaphore operation within 1s
Obtain the semaphore operation within the time range for many times, so as to ensure timely "feeding the dog".
In addition, it should be noted whether there are tasks in the system that have higher priority than TaskMonitor and are in the execution state for a long time, and TaskMonitor cannot be scheduled for a long time, causing the watchdog to reset incorrectly. Good task division, configuration should not have this kind of long-term execution of high-priority tasks.
Cable Installation Machines And Tools
Our hydraulic cable cutter is suitable for cutting down the copper, aluminum, or other metal cables. Its item number is 21437. This product weighs 10.9kg and its shear force reaches 100kN. The maximum diameter of applicable cable is 105mm.
This cutter can be connected with Manual Pump through quick coupling, which makes our product possess light weight and also makes the operating position unlimited. This manual pump is purchased additionally with the item number of 16162 or 16163.
This dual-purpose Cable Stripper is capable of cutting off the semi-conducting layer as well as the insulating layer with the voltage of 110kV or below.
Electric Winch,Cable Puller,Cable Reel Trailer,Cable Turning Roller,Motorized Cable Polishing Tool,Fiberglass Duct Rodder
MARSHINE , https://www.puller-tensioner.com