SR (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


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

Please see the RS function block for a "Reset" dominant flip-flop.

 

Input:

S1 : BOOL (true/false)

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

 

R : 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 "S1", and it will be inactive if a leading edge is seen on "R".

 

Declaration:

FUNCTION_BLOCK SR;
VAR_INPUT
  S1 : BOOL; | Set signal
  R : 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 : SR; // Declare an instance of the SR functionblock
END_VAR;
 
PROGRAM test;
 
BEGIN
  flipflop(S1:= set, R:=reset); // Input the signals to the flip-flop
  signal := flipflop.q; // output from the flip-flop
END;
END_PROGRAM;