Bit Rotation (T14)
FB(BX:= BOOL1, BXF:= BOOL2, NUMOFENABLEDOUTPUTS:= INT1);
Bit rotation shifts and rotates bits in a vector, based on rising or falling edges on the inputs.
||Rising edge input: the vector rotates one position forward at the rising edge
||Falling edge input: the vector rotates one position forward at the falling edge
||Initial bit pattern of the outputs
|LIST OF ENABLED
||Field of output numbers which take part in the rotation
|NUM OF ENABLED OUTPUTS
||Number of items that take part in the rotation
||Output rotated vector
||Indication on how many position the vector is rotated
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.
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.