📜 ⬆️ ⬇️

Hardware "watchdog" or an indispensable tool in the fight against hang

In one company there were many terminals, and one of the ungrateful tasks for technical support is to travel to points and restart the operating system inside the terminals. It was decided to challenge this problem in the form of developing a hardware watchdog timer.

As a result, we got a device that connects to the expansion paired USB-connector on the motherboard.


')

This device has the following features:

  1. Simulation of pressing buttons POWER and RESET;
  2. USB power management (provided it does not have a separate source);
  3. Control galvanically isolated contact group (relay). You can put in the cut of the food chain;
  4. Indicator LEDs (one can be controlled, the second shows the modes of operation).


The operation algorithm is simple: inside there are two adjustable timers that constantly count down the specified time, after which the press of the corresponding buttons (POWER and RESET) is simulated. To prevent an accidental reboot, you must periodically send a timer reset command.

It is better that the target application be responsible for the reset of the timers, and not a third-party or system (Cron, scheduling service) due to the fact that the probability of a system failure is less than in the application (although, who has it).
The exchange of information is similar to the console.

Command system:

teamDescriptionExample
helpCommand Summaryhelp
LED1LED control off by defaultLED1 ON
LED1 OFF
RelayRelay control, enabled by defaultRELAY ON
RELAY OFF
KEY1Imitation of pressing the button 1, not pressed by defaultKEY1 ON
KEY1 OFF
KEY2Imitation of pressing a button 2, not pressed by defaultKEY2 ON
KEY2 OFF
C1Control of timer 1 associated with button 1.
Set the time in seconds, the maximum value of 32767.
To disable the timer function, you must set the time to 0.
C1 res
C1 SET 60
C1 SET 0
C2Timer 2 control associated with button 2.
Set the time in seconds, the maximum value of 32767.
To disable the timer function, you must set the time to 0.
C2 RES
C2 SET 60
C2 SET 0
USBUSB power management enabled by defaultUSB ON
USB OFF


If successful, the command returns "OK".
In case of incorrect data returns “ERROR”.
A sign of the end of the line is the carriage return character "\ r". Also supported mode is "\ r \ n".



The device is based on an STM32F103CA controller with USB hardware support. Library of work with USB version V4.0.0. 3.3V operation voltage is obtained using a 5V line to USB stabilizer. All control circuits use transistors in key mode. Also, do not forget about the protective diode from self-induction currents in the relay coil (in my case it turned out to be built-in).

That's all - simple and angry =).

Github

Source: https://habr.com/ru/post/255261/


All Articles