R_TRIG

R_TRIG 1:

Detector for a Rising Edge

VAR_INPUT

VAR_INPUT
    CLK     : BOOL; (* Signal to detect *)
END_VAR

VAR_OUTPUT

VAR_OUTPUT
    Q       : BOOL; (* Edge detected *)
END_VAR
VAR
    M       : BOOL; 
END_VAR

The output Q and the help variable M will remain FALSE if the input variable CLK is FALSE. As soon as CLK returns TRUE, Q will first return TRUE, then M will be set to TRUE. This means each time the function is called up, Q will return FALSE until CLK has falling edge followed by an rising edge.

Requirements

Development environment

Target system type

PLC libraries to include

TwinCAT Version >= 2.6.0

PC or CX (x86)

Standard.Lib

TwinCAT Version >= 2.6.0

BC (165)

Standard.Lb6

TwinCAT Version >= 2.9.0

BCxx50 or BX

Standard.lbx

TwinCAT Version >= 2.10.0 Build >= 1301

CX (ARM)

Standard.lib