RS — Reset-dominant bistable

Pin layout

DirectionNameTypeDescription
InputSBOOLSet — sets Q1 to TRUE
InputR1BOOLReset (dominant) — wins over S when both are TRUE
OutputQ1BOOLLatched state

RS vs. SR

Two flip-flop variants:

FBSet inputReset inputPriority
RSSR1Reset wins
SRS1RSet wins

The “1” suffix marks the dominant input. Pick RS when safety considerations require that an active reset always overrides a set request (e.g. emergency-stop systems); pick SR when an active set request must override a release (e.g. latching alarms).

Syntax

VAR
    flagLatch : RS;
END_VAR

flagLatch(S := xSetCondition,
          R1 := xResetCondition);

IF flagLatch.Q1 THEN ... END_IF;

Semantics

Per Annex F.4.2, evaluated on each call:

  • If R1 = TRUE: Q1 := FALSE (reset wins).
  • Else if S = TRUE: Q1 := TRUE.
  • Else: Q1 keeps its previous value.

So the truth table:

SR1Q1 (next)
FFunchanged
TFTRUE
FTFALSE
TTFALSE (R1 wins)

When to use RS instead of a plain BOOL

A plain BOOL requires explicit assignment whenever the value should change. An RS encodes the “set on this condition, reset on that condition” pattern declaratively, which is clearer than the equivalent IF/ELSIF cascade — and importantly makes the priority explicit in the FB choice.

(* Equivalent — but reading the FB version, the reset-dominance
   is obvious from the type, no need to inspect the IF order *)
IF xResetCondition THEN
    xLatch := FALSE;
ELSIF xSetCondition THEN
    xLatch := TRUE;
END_IF;

(* vs. RS *)
flagLatch(S := xSetCondition, R1 := xResetCondition);
xLatch := flagLatch.Q1;

IEC reference

IEC 61131-3 third edition (2013), Annex F.4.2 (RS). The set-dominant SR is in F.4.1.

matiec conformance

Implemented per the standard. The pin-name spelling (R1 not R) is the most common LLM mistake — see llm_signals.