SR (Set-Reset Flip-Flop (Set-Dominant))
A set-dominant flip-flop that latches TRUE when the set input is active.
Description
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:
- S = TRUE, R = FALSE: output becomes
TRUE - S = FALSE, R = TRUE: output becomes
FALSE - S = TRUE, R = TRUE: output becomes
TRUE(set-dominant) - S = FALSE, R = FALSE: output retains its previous value
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).
Syntax
- name: the output variable name (the latch the flip-flop maintains)
- description: human-readable description of the action
- qualifier:
ActionQualifierenum (default:ActionQualifier.N) - instruction:
ActionInstruction.SR - operands:
[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.
Syntax
Sequence Visual Editor

The first chip is the dominant set input, the second the reset input.
Python
from automation_machine import Sequence, StepType, ActionInstruction, ActionOperand
class Example(Sequence):
def setup(self):
step = self.add_step(StepType.INITIAL, name="StepName")
step.add_action(
"latch_var",
"Set-dominant latch driven by start/stop buttons",
instruction=ActionInstruction.SR,
operands=[
ActionOperand("start_btn"),
ActionOperand("stop_btn"),
],
)
See Also
- RS (Reset-Set Flip-Flop): reset-dominant version
- S (Set / Stored Qualifier): simple latch on
- R (Reset Qualifier): simple latch off
- Action Qualifiers Overview
- Instructions Overview