Edge detection instructions
313
Part II IEC Instructions
F_TRIG
Falling 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 F_TRIG declare the following:
CLK signal input
the output Q is set for each falling edge at the signal input (clk = clock)
Q signal output
is set if a falling edge is detected at CLK.
PLC types Availability of F_TRIG (see page 1320)
The output Q of a function block F_TRIG remains set for a complete PLC cycle
after the occurrence of a falling edge (status change TRUE -> FALSE) at the CLK
input and is then reset in the following cycle.
Data type I/O Function
input CLK detects falling edge at input clock
BOOL
output Q is set if falling edge is detected at
input
Description
The function block F_TRIG (falling edge trigger) allows you to recognize a falling 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 F_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 falling edge is detected at signal_input.
LD
ST
When programming with structured text, enter the following:
copy_name( CLK:= signal_input ,
Q=> signal_output );