Table of Contents

Bit rotation

Block name

T14_BIT_ROTATION

ST call

PROGRAM TEST14
 VAR 
        INT1,INT2,INT3,INT4: INT;
       BOOL1,BOOL2,BOOL3,BOOL4,BOOL5,BOOL6,BOOL7,BOOL8: BOOL;
      FB: LIB.HVAC.V1_0.T14_BIT_ROTATION;
 END_VAR
 FB.INI[1]:=BOOL3;
   FB.INI[2]:=BOOL4;
   FB.INI[3]:=BOOL5;
   FB.LISTOFENABLED[1]:=INT2;
  FB.LISTOFENABLED[2]:=INT3;
  FB.LISTOFENABLED[3]:=INT4;
  FB(BX:= BOOL1, BXF:= BOOL2, NUMOFENABLEDOUTPUTS:= INT1);
    BOOL6:=FB.OUT[1];
   BOOL7:=FB.OUT[2];
   BOOL8:=FB.OUT[3];
END_PROGRAM

Library

LIB\HVAC

Version

V1.0

Description

Bit rotation shifts and rotates bits in a vector, based on rising or falling edges on the inputs.

Inputs

Input Type Description Default value
BX BOOL Rising edge input: the vector rotates one position forward at the rising edge False
BXF BOOL Falling edge input: the vector rotates one position forward at the falling edgeFalse
INI MULTIIOBOOLInitial bit pattern of the outputs [True, False,…,False]
LIST OF ENABLED MULTIIOINT Field of output numbers which take part in the rotation [1,0,…,0]
NUM OF ENABLED OUTPUTSINT Number of items that take part in the rotation 1

Outputs

InputType Description
OUT MULTIIOBOOLOutput rotated vector
SHIFTINT Indication on how many position the vector is rotated

Function

Note: The function block uses own library types: multiiobool and multiioint, which are arrays (array [1…16]) of boolean and integer values respectively. To convert it to individual binary / integer values, use the helper_multiinbool and helper_multioutbool functions, which decompose the array to a set of binary or integer values.

The INI variable must contain the initial pattern, typically “1 of n”, “2 of n” etc., e.g. [1, 1, 0, 0, 0, 0, 0, 0]. When rotating, the pattern moves “forward”, so after the first pulse the vector reads [0, 1, 1, 0, 0, 0, 0, 0], and the SHIFT variable is 1, after the second pulse [0, 0, 1, 1, 0, 0, 0, 0], and SHIFT = 2 etc. After the number of pulses equal to NUM OF ENABLED OUTPUTS the vector is back in the initial state, and SHIFT = 0.

In the NUM OF ENABLED OUTPUTS variable the number of inputs to take part in the rotation is specified; with maximum of 16.

The variable ListOfEnabled is an array with output numbers that take part in the rotation. For example, for the first 8 outputs the vector reads [1, 2, 3, 4, 5, 6, 7, 8]. (Typical usage is  n outputs in a row. If five outputs are part of the rotation, namely 1, 3, 4, 5, and 7, the vector reads [1, 3, 4, 5, 7] and NUM OF ENABLED OUTPUTS is equal to 5.

The variables above can be used if some of the outputs shall be excluded from the rotation pattern, e.g. because of boiler failure.

Application example

The block is used as a signal source for rotation of boilers, cyclical switching of pumps, multi-stage electrical heaters, etc. to load all elements in a similar way in the long term.