WAIT / WAIT_TIME

Statement - Suspend the execution of a STClosed "Structured text" A high-level language that is block structured and syntactically resembles Pascal program.

The WAIT instruction provides an easy way to program a state machine. This avoids the use of complex CASE structures.

Syntax

WAIT <BOOL expression> ;

WAIT_TIME <TIME expression> ;

Remarks

The WAIT statement checks the attached Boolean expression and does the following:

The WAIT_TIME statement suspends the execution of the program for the specified duration. The execution of other programs is not affected.

These instructions are available in ST language only and has no correspondence in other languages. These instructions cannot be called in a User-Defined Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. (UDFBClosed "User Defined Function Block" UDFB can be used as a sub-function block in another program of the application. It is described using FBD, LD, ST or IL language. Input / output parameters of a UDFB (as well as private variables) are declared in the variable editor as local variables of the UDFB). The use of WAIT or WAIT_TIME in a UDFB provokes a compile error.

WAIT and WAIT_TIME instructions can be called in a sub-program. However, it can lead to some unsafe situation if the same sub program is called from various programs. Re-entrancy is not supported by WAIT and WAIT_TIME instructions. Avoiding this situation is the responsibility of the programmer. The compiler outputs some warning messages if a sub-program containing a WAIT or WAIT_TIME instruction is called from more than one program.

These instructions must not be called from ST parts of SFCClosed "Sequential function chart" It can be used to program processes that can be split into steps. The main components of SFC are: - Steps with associated actions - Transitions with associated logic conditions - Directed links between steps and transitions programs. This makes no sense as SFC is already a state machine. The use of WAIT or WAIT_TME in SFC or in a sub-program called from SFC provokes a compile error.

These instructions are not available when the code is compiled through a "C" compiler. Using "C" code generation with a program containing a WAIT or WAIT_TIME instruction provokes an error during post-compiling.

These statement are extensions to the standard and are not IEC61131-3Closed IEC 61131-3 is the third part of the open international standard IEC 61131. The current (second) edition was published in 2003. IEC 61131-3 currently defines five programming languages for programmable control systems It deals with programming languages and defines two graphical and two textual PLC programming language standards compliant.


  • This instruction should not be used inside UDFBs. This instruction is not UDFB safe.

ST Language

(* use of WAIT with different kinds of BOOL expressions *)
WAIT BoolVariable;
WAIT (diLevel > 100) AND NOT bAlarm;
WAIT SubProgCall ();
(* use of WAIT_TIME with different kinds of TIME expressions *)
WAIT_TIME t#2s;
WAIT_TIME TimeVariable;