MAXWAIT Command

Purpose

Defines the time the block waits for the condition specified in a subsequent WAITFOR or WAITSTAT command to occur.

Syntax

MAXWAIT value

Parameter

value – specifies the number of seconds (0-32767 seconds) you want to wait. The value you enter should be an exact multiple of the chain's scan time. If it is not, the value is rounded to the next highest multiple of the block's scan time at run-time. Note that the value 0 means to wait forever.

For example, if you specify a MAXWAIT of 60 seconds and the block has a scan block of 25 seconds, the MAXWAIT command suspends the block for 75 seconds because the MAXWAIT period extended into the block's third scan period.

Examples

The MAXWAIT command applies to all subsequent WAITSTAT and WAITFOR commands unless another MAXWAIT command occurs. For example:

MAXWAIT 60
WAITSTAT PID1 AUTO
WAITFOR AI1 10
MAXWAIT 5
WAITSTAT SUBPROG1 ON

In this program, the block waits a maximum of 60 seconds for PID1 to be switched to Automatic mode and another 60 seconds for the output of AI1 to equal 10. But the block only waits a maximum of 5 seconds for SUBPROG1 to be placed on scan.

The MAXWAIT command also applies to called Program blocks. For example:

MAXWAIT 60
CALL PROG2
SETAUTO AI1

These commands instruct the Program block to wait a maximum of 60 seconds before it switches AI1 to Automatic mode. The SETAUTO command is then processed within 60 seconds regardless of whether PROG2 has processed all of its commands.