A set-dominant flip-flop that latches TRUE when the set input is active.
The SR instruction implements a set-dominant flip-flop, as defined in IEC 61131-3. It has two inputs: Set (S) and Reset (R). When both inputs are TRUE simultaneously, the Set input wins and the output is TRUE.
Behavior summary:
TRUEFALSETRUE (set-dominant)Use SR when the "on" condition must take priority over the "off" condition in conflict situations.
If you need the reset to take priority instead, use the RS - Reset-Set Flip-Flop.
ActionQualifier enum (default: ActionQualifier.N)ActionInstruction.SR[ActionOperand("set_input"), ActionOperand("reset_input")] - operand[0] is the Set input, operand[1] is the Reset input
SRrequires both operands. Without them, S and R both default toFALSEand the latch never moves. The Sequence visual editor and the runtime both warn when operands are missing.
{GIF:HERE} - Screenshot showing a step named "StepName" with an action on "latch_var" using the SR (set-reset flip-flop) instruction, with the Set and Reset input variables specified in the two operand fields
from automation_machine import Sequence, StepType, ActionInstruction, ActionOperand
class Example(Sequence):
def setup(self):
step = self.add_step(StepType.INITIAL, name="StepName")
# `latch_var` follows the set-dominant flip-flop logic of `start_btn` (S) and `stop_btn` (R).
step.add_action(
"latch_var",
"Set-dominant latch driven by start/stop buttons",
instruction=ActionInstruction.SR,
operands=[
ActionOperand("start_btn"), # Set (S)
ActionOperand("stop_btn"), # Reset (R)
],
)