WAIT / WAIT_TIME
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:
- If the expression is TRUE, the program continues normally.
- If the expression is FALSE, then the execution of the program is suspended up to the next PLC "Programmable Logic Controller" A Programmable Logic Controller, PLC, or Programmable Controller is a digital computer used for automation of industrial processes, such as control of machinery on factory assembly lines. Used to synchronize the flow of inputs from (physical) sensors and events with the flow of outputs to actuators and events cycle. The Boolean expression will be checked again during next cycles until it becomes TRUE. The execution of other programs is not affected.
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 Block A function block groups an algorithm and a set of private data. It has inputs and outputs. (UDFB "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 SFC "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-3 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;