Bistable function blocks (latches)
Both SR and RS are set/reset latches with one Boolean output Q1. They
differ in which input wins when set and reset are asserted at the same time.
SR — set-dominant
Section titled “SR — set-dominant”| Direction | Name | Type | Meaning |
|---|---|---|---|
| Input | S1 | BOOL | Set (dominant) |
| Input | R | BOOL | Reset |
| Output | Q1 | BOOL | Latch output |
When both S1 and R are TRUE, set wins and Q1 stays TRUE.
FUNCTION_BLOCK SRVAR_INPUT S1 : BOOL; R : BOOL;END_VARVAR_OUTPUT Q1 : BOOL;END_VAREND_FUNCTION_BLOCKVAR latch : SR;END_VAR
latch(S1 := startCmd, R := stopCmd);running := latch.Q1;RS — reset-dominant
Section titled “RS — reset-dominant”| Direction | Name | Type | Meaning |
|---|---|---|---|
| Input | S | BOOL | Set |
| Input | R1 | BOOL | Reset (dominant) |
| Output | Q1 | BOOL | Latch output |
When both S and R1 are TRUE, reset wins and Q1 becomes FALSE.
FUNCTION_BLOCK RSVAR_INPUT S : BOOL; R1 : BOOL;END_VARVAR_OUTPUT Q1 : BOOL;END_VAREND_FUNCTION_BLOCKVAR safeLatch : RS;END_VAR
safeLatch(S := startCmd, R1 := emergencyStop);running := safeLatch.Q1; // emergency stop always wins