(under construction)
Description:
The soft-power and watchdog are enabled by a small Python script that is run from rc.local. This script interfaces with the circuit using GPIO4. Most of the time, this signal is configured as input, so the script can monitor the status of the remote-control signal [RMT] on pin 3 of the screw terminals. Every 250 milliseconds, the GPIO is momentarily changed to an output having opposite logic polarity as the actual input signal. This overrides the fairly high impedance input signal, and results in the pulse for the watchdog controller (a tiny PIC10F320) to reset the guard time. After power-on the watchdog timer sleeps for 4 seconds to prevent signal bounce from starting this shutdown watchdog. After these 4 seconds the watchdog waits for the first pulse before the actual watchdog is enabled. This enables an arbitrary long boottime, or no watchdog script at all. Actually, without the script, the power supply works almost as any other power supply, which runs until the input power is cut.
It is also possible to start the system with a short pulse, and initiate shutdown with a second pulse. This way, the Pi works just like a regular PC with a soft power switch. The start pulse should last no longer than until the start of the watchdog script. The stop pulse should last no longer than the actual shutdown of the system, or the system will simply restart.
When the Raspberry Pi shuts down, the script is stopped, hence the pulses stop as well. After 16 seconds, results in a reset pulse from the watchdog monitor, that reset pulse disables the 5V regulator, which shuts the Pi down. After the 5V has dropped enough to disable the watchdog IC, the power control depends on the Remote input signal. If still active, the Pi will restart, otherwise it stays off until the next activation of the Remote input signal.
Note that this power control method does not support the reboot command. The hardware will hard reset the Pi after 16 seconds of missing watchdog reset pulses, and that is not enough for a reboot of the Raspberry Pi. As a substitute, an ordinary shutdown will result in a reboot if the RMT input signal is still active.
CPU load of the script is less that measurable; both ps -p <pid> -o %cpu and top -p <pid> display a CPU usage of 0.0%, with top showing 0.3% incidentally.
Todo: modify the watchdog script such that the time between the reset pulses depends on the CPU load. This changes the watchdog activity LED into a CPU load monitor, such as is very common on embedded controllers.