Hardware version as promised many many posts ago.
input comes from the output of the system via a safety isolating transformer. (it could be full wave rectified if you want).
If the voltage is in the centre dead band the clock is inhibited. If it is below the lower threshold it counts up, and if it is above the higher threshold it counts down. The output form TC inhibits the clock if it reaches zero or 15.
The final gate of the 74HC132 forms an oscillator which provides the clock pulses. About 1Hz or slower should do.

input comes from the output of the system via a safety isolating transformer. (it could be full wave rectified if you want).
If the voltage is in the centre dead band the clock is inhibited. If it is below the lower threshold it counts up, and if it is above the higher threshold it counts down. The output form TC inhibits the clock if it reaches zero or 15.
The final gate of the 74HC132 forms an oscillator which provides the clock pulses. About 1Hz or slower should do.





