Edge detection instructions
312
Part II IEC Instructions
R_TRIG
Rising edge trigger
To add an enable input and enable output to the instruction, select [With EN/ENO] from the
"Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the
context menu or press <Ctrl>+<Shift>+<v> in the programming window.
For R_TRIG declare the following:
CLK signal input
the output Q is set for each rising edge at the signal input (CLK = clock)
Q signal output
is set when a rising edge is detected at CLK.
PLC types Availability of R_TRIG (see page 1330)
The output Q of a function block R_TRIG remains set for a complete PLC cycle
after the occurrence of a rising edge (status change FALSE -> TRUE) at the CLK
input and is then reset in the following cycle.
Data type I/O Function
input CLK detects rising edge for clock
BOOL
output Q set when rising edge detected
Description
The function block R_TRIG (rising edge trigger) allows you to recognize a rising edge at an input.
Data types
Example
In this example, the same POU header is used for all programming languages. For an example
using IL (instruction list), please refer to the online help.
POU header
All input and output variables which are used for programming the function block R_TRIG are
declared in the POU header. This also includes the function block (FB) itself. By declaring the FB
you create a copy of the original FB. This copy is saved under copy_name, and a separate data
area is reserved.
Body
Signal_output will be set, if a rising edge is detected at signal_input.
LD
ST
When programming with structured text, enter the following:
copy_name( CLK:= signal_input ,
Q=> signal_output );