PC WATCHDOG SYSTEM

by FORTHRIGHT Systems and Consulting, Inc.

5414 N 99th Street
Kansas City, KS 66109

Voice: (888-349-7501 -or- (913)299-9240
Fax: (913)299-9447
http://www.forthrt.com
E-Mail: stan@forthrt.com

Table of Contents

  Installing the Hardware
    Installing the Watchdog Logic Card
    Installing the Y-Cable
  Software Installation
    Verifying the hardware with WATCHTST.EXE
    Installing WATCHDG.SYS
  Programming with the WATCHDOG Device
    Interrupt/Callback Commands
    Read Commands
    Watchdog Commands
    Programming via INT=xx Support
  Using the Supplied Applications
    Using WATCHAPP.EXE with Windows
    Using DOSTSR.COM for DOS
  Technical Information
  PC Watchdog Options
    Interval Selection
    Contact Closure

Installing the Hardware

Two components of the PC Watchdog System must be installed inside the case of your computer. First, power down the computer and remove the case according to manufacturer's directions.

Installing the Watchdog Logic Card

The Watchdog Logic Card can be inserted into any available 8- or 16-bit card slot in the PC. Simply remove the screw and metal cover for the selected slot at the back of the PC, insert the card by sliding straight down into the card slot, and then screw it down. NEVER insert the expansion card into the computer with the computer power on.

The Watchdog Logic Card must be set to a suitable hardware address within your PC to allow it to function and to prevent it from interfering with other equipment. The card address is configured via 8 pencil switches on the top edge of the card. The factory setting for the switches is 2E4, though you are free to change the address as suits your PC's environment. The individual switch positions are Down/On when the lever is toward the circuit board, and Up/Off when the lever is away from the circuit board.

Address configuration switches, switch 1 is nearest to the back of the computer.

    Switch Value    Switch  Value    Switch Value
     1  2   x--     3 4 5 6  -x-      7  8   --x
     d  d   0       d d d d   0       d  d     0
     d  u   1       d d d u   1       d  u     4*
     u  d   2*      d d u d   2       u  d     8
     u  u   3       d d u u   3       u  u     C
                    d u d d   4
                    d u d u   5
                    d u u d   6
                    d u u u   7
                    u d d d   8
                    u d d u   9
                    u d u d   A
                    u d u u   B
                    u u d d   C
                    u u d u   D
                    u u u d   E*
                    u u u u   F
    * indicates factory default for address

Installing the Y-Cable

The Y-Cable is installed between the PC's power supply and the system board, with a connection to the Watchdog Logic Card. The cable needs to be installed only if you want the PC Watchdog System to be able to reset your PC. If you are using the system exclusively to generate interrupts, this step isn't necessary -- but neither will it hurt.

The PC power supply is generally a large silver box located at the back, right corner of your PC. Typically, it has a bundle of brightly colored wires emerging from it. Two groups of six wires each go to the main board at the bottom of the computer in side-by-side connectors. Frequently the connectors are labelled P8 and P9 (sometimes P1&P2 or P11&P12). We are interested in the P8 connector. It should have two black wires at the right side, with the other four wires each being a different color. (The P9 connector generally has two black wires on the left, and three red wires on the right, with some other color in the middle.)

Remove the P8 (or P1 or P11) connector from the system board (pull up then tip it as if to lay the wires flat). Connect it to the male connector on the Y-Cable board. Then connect the large connector of the Y-Cable to the system board where P8 was. Finally, connect the small connector on the multicolored ribbon to the pins on the Watchdog Logic Card next to the switches.

Note: There is one slide switch on the Y-Cable board. When at the factory setting, slid toward the outer edge of the board, the PC will load normally. It will not test to ensure the PC Watchdog System is available. If the switch is slid toward the center of the board, the PC will not start processing unless the Watchdog Logic Card is in place AND connected via the multicolored ribbon cable, although the power supply fan may run. Factory setting should be appropriate for most applications.

Software Installation

The included diskette contains several files. These should be copied to your hard disk for accessibility. This can be accomplished by issuing the following DOS commands:

    C:
    MKDIR C:\PCWATCH
    CD C:\PCWATCH
    COPY A:*.* C:\PCWATCH\*.*

Verifying the hardware with WATCHTST.EXE

WATCHTST is a program that tests the interface between your processor and the Watchdog System's Logic Card. From a DOS prompt, type C:\PCWATCH\WATCHTST followed by any selected options and then press ENTER. If no options are selected, the IRQ test will be run on all IRQs. If the operator approves, a LOAD test will then be executed.

WATCHTST Options:

    addr        the configured address if not 2E4
    IRQ(n)      run the IRQ tests (all or IRQ n)
    LOAD(intv)  reload (now or after interval)
WATCHTST first verifies that it can communicate with the Watchdog Logic Card at the designated address.

The IRQ test verifies whether IRQs (hardware interrupts) can be generated successfully by the board. This information is necessary if you want to use the programmable callback features of the driver.

The LOAD test requests a PC reload after the specified interval (immediate if unspecified). This option can be used to communicate with the board even without the device driver loaded. The interval is specified as a count and rate. The count can be anywhere from 0 to 15. The rate can be any of: 4u, 32u, 250u, 2m, 16m, 128m, 1s or 8s. (u means micro/millionth of a second, m stands for milli/thousandth second, s stands for seconds.) The reload will take place after count intervals of the given rate have taken place. An interval of "off" will cancel a previous reload request.

For example, WATCHTST LOAD(15@8s) will schedule a load for 2 minutes from now (15 intervals * 8 seconds = 120 seconds or 2 minutes). An immediate load can be requested by WATCHTST LOAD(0@4u). WATCHTST LOAD(off) will cancel a previous watchdog load request.

Installing WATCHDG.SYS

WATCHDG.SYS provides a DOS device driver to communicate between the PC Watchdog System and your application. It provides a simple character-based control language for issuing commands to the board and generating callbacks to your application. Before using the device driver, you must have loaded the driver to your hard disk, configure it to your CONFIG.SYS file and restart your computer.

Add the following line to your CONFIG.SYS file. This file is normally in the root directory of your hard disk drive, as C:\CONFIG.SYS. Use an editor (EDIT or EDLIN or other of your choice) to edit the file, adding:

    DEVICE=C:\PCWATCH\WATCHDG.SYS [options]
where options are:
    ADDR=addr  device address (required if not 2E4)
    IRQ=n      hardware IRQ (required for callbacks,
               valid choices detected by WATCHTST)
    TABLE=n    number of callback routines supported
               (default 10 if IRQ specified & valid)
    INT=xx     software interrupt to use as an additional
               way to communicate with the system,
               defaults to no support.
Finally, restart your system. You will receive status messages during startup concerning the load and configuration of the device driver.

Programming with the WATCHDOG device

The device driver provides a set of commands for working with the watchdog system. These can be issued by reading and writing from the device named WATCHDOG. (The WATCHDOG device is created by loading the device driver through CONFIG.SYS, as described above.)

All commands are strings of letters (either upper, lower or mixed cases) ending with a carriage return (x0D), linefeed (x0A) or both. These can be generated from the keyboard using the DOS echo command, as follows:

      ECHO [command] >WATCHDOG

or programmatically by opening and writing to the WATCHDOG file.

The available commands begin with one of three characters: I, R or W. The I commands set callback/interrupt requests on or off. The R commands prepare information to be read from the watchdog device concerning the status of watchdog and/or callback/interrupt requests. The W commands are used to set the watchdog timer on or off.

The following notation is used to describe the commands:

  cnt        Timing Count, a decimal number in the range 0-15
  intv       Timing Interval, a member of the following list:
             4u, [31 or 32]u, [250 or256]u, 2m, 16m, 128m, 1s, 8s
  ssss:oooo  Segment:OffSet Address for callback handler where 
             ssss and oooo are hexadecimal character strings
  xx         Interrupt Number as a hexadecimal character string

The following are the available commands:

  Issss:oooo/cnt@intv  Set callback routine and timer
  Issss:oooo/_         Remove specific callback from table
  Ixx/cnt@intv         Set interrupt routine and timer
  Ixx/_                Remove interrupt xx from callback table
  I*/_                 Remove all interrupts/callbacks from table
  R                    Read WATCHDOG settings
  Rssss:oooo           Read specific callback timer settings
  Rxx                  Read specific interrupt timer settings
  R*                   Read WATCHDOG and all callback/interrupt 
                       timer settings
  Wcnt@intv            Set WATCHDOG timer
  W_                   Clear WATCHDOG timer

INTERRUPT/CALLBACK Commands

Callback routines are routines that are called by CALL FAR from the device driver at the requested rate. The called routine should return with a RET FAR instruction. Once set, the routine is called on every such occasion until the callback entry is removed from the device driver where both the address and the rate are stored.

The rate may vary slightly due to the processing of other callback routines. It may be slightly off for the first interval after being set, or during an interval when a new item which runs at a higher rate is added to the driver table.

A callback routine may be added, updated or removed from the table at any time. It may be re-entered if callback processing time exceeds the callback rate. The user is expected to take appropriate precautions in this event. When callback servicing is running seriously behind, there may be occasions where a callback will not be made before the next callback is due. If this problem occurs, reduce the callback processing or get a faster processor.

Interrupt routines are very similar to callback routines. They are entered, however, via a software interrupt and must end with an IRET (or equivalent) instruction. Software interrupts get their address from the interrupt vector table.

Callback and interrupt routines can be turned off by requesting the routine with a cnt@intv specification of "_" (underscore).

READ Commands

The 'R'ead commands prepare new data for delivery in response to a read from the WATCHDOG device. Any undelivered data is discarded. From DOS, use the command COPY WATCHDOG CON to see the response to a read command, or programmatically read from the WATCHDOG file. Each item read from the watchdog device ends with a CR/LF pair.

Reading the WATCHDOG request state will respond with either "Watchdog / Inactive" or "Watchdog / cnt@intv" indicating the last setting sent to the watchdog card. There is no way to determine remaining time from the card.

Reading an interrupt or callback request state will respond with either "ssss:oooo/cnt@intv" or "Sw Int xx/cnt@intv" to indicate the current request state. Again, no provision is made to determine time remaining before the next callback.

WATCHDOG Commands

A watchdog request indicates that the hardware should monitor for a given time (cnt@intv) for a new request. If a new request is not received within this time, the PC is restarted. The watchdog monitor may also be turned off with a "_" (underscore) request in leiu of a cnt@intv.

Programming via INT=xx Support

If supplied on the DEVICE= line in CONFIG.SYS, the device driver can also accept commands via a software interrupt. To utilize interrupt services, load the processor registers as described below then issue the specified software interrupt. On success the CARRY flag will be clear. In event of errors, CARRY will be set and AX will contain an error code.

Error code list:

    1:    Invalid command request
    2:    No IRQ support, no callbacks accepted
    3:    Invalid Interrupt number (not 1-xFF)
    4:    Invalid Offset value (not 0-xFFFC)
    5:    Invalid count (not 0-15)
    6:    Invalid interval (not 0-7)
    7:    Unable to locate item to delete, or
          Unable to add item to table (full)

AH == I        Interrupt/Callback support
  CX==xFFFF        clear entry specified by DX,BX, else
      CH           is count register (0-15)
      CL           is interval (0:4u, 1:32u, 2:250u, 3:2m, 4:16m, 
                   5:128m, 6:1s, 7:8s)
  DX,BX==xFFFF     specifies all entries (for clear only)
  DX==0,BX!=0      specification for an interrupt (bx) routine,
  DX!=0,BX!=0      specifies a callback (dx:bx) routine

AH == R        Read support
  CX               buffer size available to fill
  ES:DI            buffer address to return data
  DX,BX==xFFFF     specifies read everything
  DX==0,BX==0      specifies a read of watchdog values only
  DX==0,BX!=0      specifies an interrupt (bx) routine to read
  DX!=0,BX!=0      specifies a callback (dx:bx) routine to read
Read responds with the same format as described above for reading from DOS's WATCHDOG device. CX will be updated to reflect the amount of data returned (no trailing NULL).
AH == W        Set watchdog timer
  CX==xFFFF        turn off watchdog timer, else
      CH           is count register (0-15)
      CL           is interval (0:4u, 1:32u, 2:250u, 3:2m, 4:16m, 
                   5:128m, 6:1s, 7:8s)

Using the Supplied Applications

Included with the PC Watchdog System are two applications. WATCHAPP.EXE is a program that runs on the Windows "idle" processing list, which is normally called many times a second. DOSTSR.COM is a program for use with DOS that installs itself in memory and watches for DOS requests. Both of these programs work in the idle time in their respective environments, and a failure will cause the Watchdog to reset the PC.

Using WATCHAPP.EXE with Windows

WATCHAPP.EXE is a WINDOWS application that tells the PC WATCHDOG SYSTEM hardware, via the WATCHDOG.SYS device driver, that WINDOWS is still running (so long as it really is running).

You must have previously installed and tested the hardware as indicated in previous sections of this manual. You must also load the WATCHDG.SYS device driver as described earlier. Testing the WATCHAPP application should be deferred until after hardware has been verified to work in DOS.

The WATCHAPP application can be started by any WINDOWS-acceptable method you choose. Creating a WATCHAPP icon in the STARTUP group is suggested. From Program Manager select the STARTUP Group, then open the FILE menu and select NEW PROGRAM. For description enter WATCHDOG APPLICATION (or some such). For command line enter WATCHAPP and any arguments you desire (see next paragraph). For working directory enter C:\PCWATCH (or wherever you copied the programs to during software installation). Click on the OK button to save your selections. The next time you start Windows, the WATCHAPP program will automatically start for you.

When WATCHAPP is started without arguments, the application sends W8@8S to the device driver every time the "idle" routine is called by WINDOWS. (This normally happens many times per second.) This tells the PC WATCHDOG SYSTEM hardware "I'm healthy for another minute" (8 intervals of 8 seconds each). WATCHAPP can be started with an argument of W15@8S to request 2-minute protection, or other values may be used as documented in the manual. If WINDOWS gets stuck, the "idle" routine won't be called and the hardware will restart your PC after the indicated time.

When WATCHAPP is exited, it turns off the watchdog protection system by writing W_ to the device driver.

Using DOSTSR.COM with DOS

DOSTSR.COM is a Terminate-and-Stay-Resident program for watching the DOS execution environment. DOSTSR does not require that the WATCHDG.SYS device driver be loaded in order to run.

When DOSTSR is started without arguments, the application sends W8@8S to the Watchdog hardware every time an Int 21 (application call to DOS), INT 28 (DOS idle), or INT 2F (application to application/DOS) call occurs. This tells the PC WATCHDOG SYSTEM hardware "I'm healthy for another minute" (8 intervals of 8 seconds each). DOSTSR can be started with an argument of W15@8S to request 2-minute protection, or other values may be used as documented, or W_ to turn it off. If DOS gets stuck (the above interrupts quit happening) the hardware will restart your PC after the indicated time.

DOSTSR loads itself into memory the first time it is executed. Subsequent executions update the resident copy's options without requiring another copy to be loaded into memory.

Technical Information

Card:    ISA Bus, 8/16 bit slot

IRQs:    3,4,5,7,9,10,11 or 12 on 16-bit slots
         2,3,4,5,7 on 8-bit slots

Interval generation (+/- 10ppm)
      0      4u    0.000003906 seconds
      1     32u    0.000031250 seconds
      2    250u    0.000250000 seconds
      3      2m    0.002000000 seconds
      4     16m    0.016000000 seconds
      5    128m    0.128000000 seconds
      6      1s    1.024000000 seconds
      7      8s    8.192000000 seconds

I/O Base Address Range:
    000 - 3FC in multiples of x04

I/O Address Usage:
    Note: Each register is a read/write register.  The last value
    written will be the value read back.

base    Watchdog Timer Register
    B'xxx-----'    Interval: 0-4u, 1-32u, ...7-8s
    B'---x----'    0-timer inactive, 1-active
    B'----xxxx'    Interval count (0-15)
base+1    unused
base+2    Interrupt Timer Register
    Note: IRQ Selection Register must be written before writing to the
          Interrupt Timer Register.  If IRQ Selection hasn't been
          previously written, the timer enable bit (x10) will be masked
          off (inactive) before writing to the register.
    B'xxx-----'    Interval: 0-4u, 1-32u, ...7-8s
    B'---x----'    0-timer inactive, 1-active
    B'----xxxx'    Interval count (0-15)
base+3    IRQ Selection Register
    B'x-------'    0-generate IRQ 2/9, 1-don't generate IRQ 2/9
    B'-x------'    0-generate IRQ 3,   1-don't generate IRQ 3
    B'--x-----'    0-generate IRQ 4,   1-don't generate IRQ 4
    B'---x----'    0-generate IRQ 5,   1-don't generate IRQ 5
    B'----x---'    0-generate IRQ 7,   1-don't generate IRQ 7
    B'-----x--'    0-generate IRQ 10,  1-don't generate IRQ 10
    B'------x-'    0-generate IRQ 11,  1-don't generate IRQ 11
    B'-------x'    0-generate IRQ 12,  1-don't generate IRQ12

External DB9 connector

Pin 1: External Interrupt (to Watchdog)
       This pin is pulled to +12V across a 10Kohm pullup resistor.  Pull to
       ground (or -12V) for 3u or longer to request interrupt generation.
       Restore to +12V to enable next interrupt. (Pin 5 PC Recover going
       low (-12V) indicates the interrupt has been posted).  While pulled
       low, board cannot generate an internal interrupt based on 
       interval/enable/count.
Pin 2: -12V (from Watchdog/PC Bus)
Pin 3: Ground
Pin 4: +12V (from Watchdog/PC Bus)
Pin 5: PC Recover (from Watchdog)
       This pin is normally high (+12V) and is driven low (-12V) when an
       interrupt occurs.
Pin 6: External Reset (to Watchdog)
       This pin is pulled to high (+12V) across a 10Kohm pullup resistor.
       Pull to ground (or -12V) and hold for .25 seconds to request a reset.
Pin 7: Watchdog Reset (from Watchdog)
       This pin is normally high (+12V) and is driven low (-12V) when the
       Watchdog timer is resetting the PC.
Pin 8: Power Supply Valid (from Watchdog/Power Supply)
       This pin is low (-12V) when the PC's Power Supply pin indicates power
       is valid, high (+12V) or 0 otherwise.
Pin 9: PC Reset (from Watchdog)
       This pin is normally high (+12V) and is driven low (-12V) when the PC
       is being reset, either by the Watchdog system, reset button or
       otherwise.

PC Watchdog Options

There are two available options for the PC Watchdog Logic board. The first option allows the use of slower intervals for interrupt and watchdog timing. The second provides a contact closure when the watchdog board either generates a reset or is told to reset via the external connector.

Interval Selection

Factory settings are both speed selection jumpers to the left for 4 micro-second and 32 micro-second. The upper jumper may be shifted right to replace 32 micro-second selection with 256 second selection. The lower jumper may be moved right to provide 64 second selection. (Actual times are 262.144 and 65.536 respectively.)

Contact Closure

Factory setting is to disable the contact closure by not jumpering the enable jumper. To enable the contact closure, install the jumper and connect to the contact closure jack just above the jumper. The contact closure rating is 10Watt max, 0.5A max, 200V max.