RS (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


RS is a function block that acts as a Reset/Set flip flop. On a leading edge on the "S" input, the "q" output will stay active. On a leading edge on the "R1" input, the "out" will stay inactive. If a leading edge is seen at the same time on both "S" and "R1", the reset function "wins" and the '"out" will stay inactive.

Please see the SR function block for a "Set" dominant flip-flop.

 

Input:

S : BOOL (true/false)

A leading edge on this signal will set the "out" to active.

 

R1 : BOOL (true/false)

A leading edge on this signal will set the "out" to inactive.

 

Output:

q : BOOL (true/false)

This signal will be active if a leading edge is seen on "S", and it will be inactive if a leading edge is seen on "R1".

 

Declaration:

FUNCTION_BLOCK RS;
VAR_INPUT
  S : BOOL; | Set signal
  R1 : BOOL; | Reset signal
END_VAR;
VAR_OUTPUT
  q : BOOL; | The output from the flip-flop
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
  set   : BOOL; | Digital input for set
  reset : BOOL; | Digital input for reset
END_VAR;
 
VAR_OUTPUT
  signal : BOOL; | Output from the flip-flop
END_VAR;
 
VAR
  flipflop : RS; // Declare an instance of the RS functionblock
END_VAR;
 
PROGRAM test;
 
BEGIN
  flipflop(S:= set, R1:=reset); // Input the signals to the flip-flop
  signal := flipflop.q; // output from the flip-flop
END;
END_PROGRAM;