ON

Statement - Conditional execution of statements.

The ON instruction provides a simpler syntax for checking the rising edgeClosedA rising edge is the transition of a digital signal from low to high. It is also called positive edge of a Boolean condition.

Syntax

ON <BOOL expression> DO
<statements>
END_DO;

Remarks

Statements within the ON structure are executed only when the Boolean expression rises from FALSE to TRUE. The ON instruction avoids systematic use of the R_TRIG function block or other "last state" flags.

The ON syntax is available in any program, sub-program or 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.

This statement is an extension to the standard and is not IEC61131-3ClosedIEC 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

(* This example counts the rising edges of variable bIN *)
ON bIN DO
   diCount := diCount + 1;
END_DO;