FORTHRIGHT Systems and Consulting

Serial Watchdog System

The SERIAL WATCHDOG allows the turning off/on of the outlets in event of program failure. This is controlled by a serial device (typically the PC whose power is being controlled). The normal configuration would be to plug the Serial Watchdog into the UPS (or wall outlet) and the PC Processor into the Serial Watchdog, then connect the serial cable between the watchdog and an available com port on the PC.

The serial port on the Serial Watchdog is designed to run with a 9-pin straight cable (supplied) to a standard PC com port. The serial.exe program can be used to issue commands to the watchdog, or PC software can manage the watchdog directly.

For the Serial Watchdog timers to be enabled, the cable must be connected and the DTR signal from the controlling device must be "ON". Without this signal the outlet is simply kept "ON" and the timers are disabled. A single byte command received on the serial port can enable or disable the watchdog timer or the DCD toggle timer. The byte format is described below under the DIRECT CONTROL heading. The RTS signal must also be "ON" to enable the Serial Watchdog to recognize the byte command. Once the byte is sent, RTS can be turned off. The SERIAL.EXE program can generate the byte command for managing the watchdog timer. The DTR signal is echoed back as DSR, the RTS signal is echoed back as CTS, and transmitted data is echoed back on the receive data line. DCD is directly managed by the Serial Watchdog for interrupt generation. Power On state for DCD is OFF. DCD is also turned off and remains each time the watchdog turns off outlet power until the interrupt timer is reprogrammed.

When the Serial Watchdog initially receives power, power to the outlets is delayed a few seconds. This is the normal function and not a problem or flaw in the Serial Watchdog. Once the watchdog timer is enabled and when it expires, the outlet power is turned off for a few seconds (4-7) and then restored. Both the watchdog and the DCD toggle timers are disabled on initial power-up and after any power-down-up cycle.


SERIAL[.exe] watchdog command structure:
    serial [port] [cnt@interval | OFF]
    port is COM1/COM2/COM3/COM4/hex_addr (default is COM1)
    cnt  is number of intervals (0=right now, 1=next occurence (may be short) to 15)
    interval is one of:
         .25  for 1/4 second interval counting
         4    for 4 second interval counting
         1    for 1 minute interval counting
         16   for 16 minute interval counting
    OFF  (either case) indicates to turn off the watchdog timer

  serial off          turn off the timer (connected on default COM1)
  serial com2 12@.25  set timer for approximately 3 seconds
  serial 2e8 4@16     set timer (com4:2e8) for 48-64 minutes
  serial com1 0@4     power down-up right now


Direct output through the serial port can also be achieved. For direct control use 19200 BPS, 8-bit, Non-parity with either 1 or 2 stop bits.

Traditional serial port definitions for PC usage (8250, 16450, 16550, 16650)
    #define TXD    0    // transmit offset            (when LCR x80 off)
    #define RXD    0    // receive offset             (when LCR x80 off)
    #define RLO    0    // divisor of rate (low byte) (when LCR x80 on)
    #define RHI    1    // divisor of rate (high byte)(when LCR x80 on)
    #define IER    1    // interrupt enable register
    #define IIR    2    // interrupt identification register
    #define LCR    3    // line control register
    #define MCR    4    // modem control register
    #define LSR    5    // line status register
    #define MSR    6    // modem status register

Traditional values of base are:
    x3F8 for COM1
    x2F8 for COM2
    x3E8 for COM3
    x2E8 for COM4

Program the port for 19200 BPS:
    outb(base+LCR, 0x83);        // access rate info
    outb(base+RLO, 0x06);        // 19200 baud
    outb(base+RHI, 0x00);
    outb(base+LCR, 0x03);        // turn off rate info access
    outb(base+MCR, 0x0F);        // turn on DTR, RTS

Output the command byte(s)
    outb(base+TXD, command);     // send command, where command is the result
                                 // of 'OR'ing the following
                                 // x80  timer selection:
                                 //      x80 write to DCD toggle timer
                                 //      x00 write to watchdog timer
                                 // x60  frequencey selection:
                                 //      x00 is 1/4 second
                                 //      x20 is 4 second
                                 //      x40 is 1 minute interval
                                 //      x60 is 15 minute interval
                                 // x10  enable/disable timer:
                                 //      x10 is enabled
                                 //      x00 is disabled
                                 // x0F  interval counter