Structured Text Components: Instructions
Structured text statements can also be instructions. A structured text instruction executes each time it is scanned. A structured text instruction within a construct executes every time the conditions of the construct are true. If the conditions of the construct are false, the statements within the construct are not scanned. There is no rung-condition or state transition that triggers execution.
This differs from function block instructions that use EnableIn to trigger execution. Structured text instructions execute as if EnableIn is always set.
This also differs from ladder diagram instructions that use rung-condition-in to trigger
execution. Some ladder diagram instructions only execute when rung-condition-in toggles from
false to true. These are transitional ladder diagram instructions. In structured text,
instructions execute when they are scanned unless pre-conditioning the execution of the
structured text instruction.
For example, the SRT instruction is a transitional instruction in ladder diagram. In this
example, the SRT instruction only executes on a scan when tag_xic transitions from cleared
to set. The SRT instruction does not execute when tag_xic stays set or when tag_xic
clears.

In structured text, if writing this example as:
if tag_xic then SRT(6,1,control2);
end_if;
The SRT instruction will execute every scan that tag_xic is set, not just when tag_xic
transitions from cleared to set.
If you want the SRT instruction to execute only when tag_xic transitions from cleared to
set, you have to condition the structured text instruction. Use a one-shot to trigger
execution.
osri_1.InputBit := tag_xic;
OSRI(osri_1);
if (osri_1.OutputBit) then
SRT(6,1,control2);
end_if;
Provide Feedback