You are here: Core Reference > Coding > Logic > RS

RS

Function Block Name

RS

Description

RS is a reset latch where the Reset is dominant over the Set. It can be used to determine the state of a Boolean output based on the states of 2 Boolean inputs.

Arguments

S {BOOL}

The Set input S only affects the Q1 output when the R1 input is False. If the S input changes from False to True and the R1 input is False, the change to the S input will cause the Q1 output to become True. The Q1 output will then stay True until the R1 state changes; Q1 will not respond to the S input changing state again until R1 has become True and then changed to False again.

R1 {BOOL}

The Reset input R1 is dominant in the RS function block. When its input is True, the Q1 output is False; when the R1 input is False, the value of the Q1 output is dependent on the S input.

Returns

Q1 {BOOL}

The Q1 output is True when the R1 input is True. When the R1 input is False, the Q1 input can respond to the S input:

  • If the S input changes from False to True and the R1 input is False, the Q1 output becomes True.
  • If the S input changes from True to False while the R1 input is False, the Q1 output remains True.
  • If the R1 input is True, the Q1 output is False irrespective of the state of S.

Example - RS Function Block Diagram:

It is easier to understand the functionality of the RS function block if you imagine the S and R1 inputs as corresponding to power buttons, and the Q1 output as the result of those buttons being pressed.

The S input receives its value from a point that represents a 'power on' button on plant; the R1 input receives its value form a point representing the 'power off' button.The True state corresponds to the buttons being pressed (active) and the False state corresponds to the buttons not being pressed (inactive).

The power on button is pressed (S is True) and the power off button is not pressed (R1 is False), so the power is on (Q1 is True). As the power on button cannot turn the power off, further changes to the S input will not affect the output (as long as R1 remains False). The power remains on until the off button is pressed (Q1 remains True until R1 becomes True).

When the power off button is pressed (R1 becomes True), the output becomes False (the power is off). The output will remain False until the R1 input changes to False (the power off button is not pressed) and the S input is True (the power on button is pressed).

If both buttons are pressed at the same time (S and R1 are both True), the R1 input is dominant and so the power is off (Q1 is False).

Example - RS ST Program:

The syntax for entering an RS function block in an ST program is:

  • VAR
    • S_IN AT %M(.Digital Point1): BOOL;
    • R1_IN AT %M(.Digital Point2): BOOL;
  • END_VAR
  • VAR
    • Q1_OUT: BOOL;
    • FB : RS;
  • END_VAR
    • FB( S := S_IN, R1 := R1_IN, Q1:= Q1_OUT );

The direct variables are declared in a separate VAR block to the indirect variables. The input and output variables for the RS function block are also allocated names that are different to the names of the inputs and outputs in the function block as this makes it easier to understand the ST program (for example, the R1 input variable is named R1_IN). In this example, the direct variables for the S input (S_IN) and R1 input (R1_IN) reference digital points (the Boolean values for the inputs are taken from digital points in the database).

In the second VAR block, the internal variables are declared, including an FB variable that defines the type of function block.

The ST Program can then reference the variables as inputs and outputs for the function block:

  • FB( S := S_IN, R1 := R1_IN, Q1 := Q1_OUT );

So, the ST Program uses the S_IN input as the S input for the FB function block (which has already been declared as an RS type). It uses the R1_IN variable as the value for the R1 input and for the Q1 output it uses the Q1_OUT variable.


ClearSCADA 2015 R2