Trigger
R_TRIG
A rising edge trigger (R_TRIG) is a function block in the IEC 61131-3 structured text language that detects a transition from a low (FALSE) to a high (TRUE) state on its input signal (CLK). When such a transition is detected, the output (Q) is set to TRUE for one cycle. If the input remains high, the output will return to FALSE on the next cycle. This function block is useful for detecting events that occur on the rising edge of a signal.
VAR
trg : R_TRIG;
in : BOOL := TRUE;
q : BOOL;
END_VAR;
trg(CLK := in, Q => q);
print(q); // True
trg(CLK := in, Q => q);
print(q); // False
F_TRIG
A falling edge trigger (F_TRIG) is a function block in the IEC 61131-3 structured text language that detects a transition from a high (TRUE) to a low (FALSE) state on its input signal (CLK). When such a transition is detected, the output (Q) is set to TRUE for one cycle. If the input remains low, the output will return to FALSE on the next cycle. This function block is useful for detecting events that occur on the falling edge of a signal.
VAR
trg : F_TRIG;
in : BOOL := TRUE;
q : BOOL;
END_VAR;
trg(CLK := in, Q => q);
print(q); // False
in := FALSE;
trg(CLK := in, Q => q);
print(q); // True
trg(CLK := in, Q => q);
print(q); // False