Allen-Bradley 1784-KTX Reference Manual page 68

Table of Contents

Advertisement

Chapter 6
Reporting KTx Scanner Status
Scanner Watchdog
6-8
Suppose that your program crashes, either because of logic errors or because
of operator intervention. Or suppose that through logic errors your program
gets into an infinite loop. In these cases the program is no longer sending
meaningful information to the scanner. Your application can configure the
scanner to detect these situations and to gracefully shut itself down when
this condition is detected. This is done by enabling the scanner watchdog.
When the scanner watchdog is enabled, the host and the scanner must
periodically handshake through the dual port to indicate they are operating
normally. Not only can the scanner detect a 'dead' host, the host can detect
a 'dead' scanner. The steps for configuring the scanner watchdog are
described below and example code follows.
The host enables and sets the period for the scanner watchdog by writing a
non-zero value in
host_dead_counter
location will disable the watchdog. The period is determined by the value
written to
host_dead_counter
Watchdog period = 20ms * value in
After enabling the scanner watchdog, the host must handshake with the
scanner before the watchdog timer expires. The handshake will cause the
scanner to reset the watchdog timer and begin timing again. The host's
handshake with the scanner consists of writing 00h in
port. The scanner returns the handshake by writing a 02h in
dual port every 20ms. The host can check the contents of
before writing to
alive_flag
00h (the host's handshake) to 02h (the scanner's handshake).
Example 6.A
and
Example 6.B
how to write an interrupt service routine that performs the Watchdog
handshake at regular intervals. The interrupt service routine is activated by
the PC's clock interrupt.
In
Example
6.A, the host configures the period of the scanner watchdog to
1000ms by writing 50 into
watchdog handshake with the scanner every 500ms. This wide margin of
error was chosen to illustrate that the programmer must take into
consideration that MS-DOS does not offer reliable real-time response.
The personal computer's clock interrupt occurs at approximately 50ms
intervals. The scanner's clock interrupt occurs at approximately 20ms
intervals. Set the
host_dead_counter
In
Example
6.A, after 10 PC ticks (~500ms), the PC clears the
The scanner tests the
alive_flag
error is intentionally high since PCs are not known to be very accurate
at timing tasks.
in the dual port. Writing a zero to this
according to the formula:
host_dead_counter
and verify the scanner changed the value from
show you how to enable the Watchdog and
. The host performs a
host_dead_counter
value to (wdg_preset * 5).
after 50 KTx ticks (1000ms). This margin of
in the dual
alive_flag
in the
alive_flag
for 02h
alive_flag
.
alive_flag

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents