LGF_ShiftRegister (FB / V1.0.3)

Overview

Author: Siemens Digital Industry Support

Short description

The Function represents a shift register for any kind of Datatype (using variant).
It is possible to shift the elements in the array at bufferRegister to the left (index array[n]:=array[n+1]) or right (index array[n]:=array[n-1]).
It could be used for material tracking trough a machine or a process, e.g. for a rotary indexing table.


Note
As this is a real shift operation, it may cause some runtime effects while using big array sizes to move at the input bufferRegister.
Please consider that a FIFO or LIFO storage, based on indexes, could be used as well for most applications.

Block Interface

LGF_ShiftRegister (FB)
Bool  shiftLeft error  Bool
    
Bool  shiftRight status  Word
    
UInt  shiftRange subFunctionStatus  Word
    
Bool  clear   
    
Bool  fill   
    
Variant  initialItem   
    
Variant  bufferRegister  Variant
       
   

Input parameter

IdentifierData type Default value Description
shiftLeftBool FALSE Rising edge: Elements in the array `bufferRegister` shifted left.
Elements moved from index `N` to `N - 1`.
The element at index `N = 0`is overwritten
shiftRightBool FALSE Rising edge: Elements in the array `bufferRegister` shifted right.
Elements moved from index `N` to `N + 1`.
The element at index `N = lastIndex` is overwritten
shiftRangeUInt 1 Number of places to be shifted in the `bufferRegister` input array
clearBool FALSE Clear buffer elements in `bufferRegister` with `initalItem`
fillBool FALSE Overwrite buffer elements after shift operation.
* `shiftLeft` - the most right element/s
* `shiftRight` - the most left element/s
overwritten by `initalItem`.
initialItemVariant --- Value with which the array at input `bufferRegister` is initialized (usually the default value)

Output parameter

IdentifierData type Description
errorBool FALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord 16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)
subFunctionStatusWord Status or return value of called FB's, FC's and system blocks

In/Out parameter

IdentifierData type Description
bufferRegisterVariant Buffer / Register memory as ARRAY, which keeps the data.
The data in the register is shifted left or right depending on the command.

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_NO_ERROR
Status: Execution finished without errors
16#7000STATUS_NO_CURRENT_JOBS
Status: No current jobs, initial state
16#8200ERR_NO_ARRAY
Error: No array is present at the input `bufferRegister`
16#8201ERR_CLEARING_WITHOUT_INITIAL_ITEM
Error: Claering `bufferRegister` without an `initialItem` is not possible.
16#8202ERR_FILL_WITHOUT_INITIAL_ITEM
Error: Option `fill` the buffer after shift operation without an `initialItem` is not possible.
16#8203ERR_WRONG_TYPE_INITIAL_ITEM
Error: The data type of the input `initialItem` does not correspond to the data type of the array at the InOut parameter `bufferRegister`.
16#8401ERR_MORE_THAN_ONE_COMMAND
Error: More than one command present at the same time. Only one of the inputs `shiftLeft`, `shiftRight` or `clear` is allowed.
16#8402ERR_IN_SHIFT_RANGE
Error: The value at `shiftRange` must not exceed the maximum size of the Array at `bufferRegister`.
16#8610ERR_CLEAR_BUFFER
Error: While clearing buffer in block `MOVE_BLK_VARIANT``. Check `subFunctionStatus` code.
16#8611ERR_SHIFT_BUFFER_LEFT
Error: While shift buffer left in block `MOVE_BLK_VARIANT` - check `subFunctionStatus` code
16#8612ERR_SHIFT_BUFFER_LEFT_FILL
Error: While fill buffer after shift left in block `MOVE_BLK_VARIANT` - check `subFunctionStatus` code
16#8622ERR_SHIFT_BUFFER_RIGHT
Error: While shift buffer right in block `MOVE_BLK_VARIANT` - check `subFunctionStatus` code
16#8622ERR_SHIFT_BUFFER_RIGHT_FILL
Error: While fill buffer after shift right in block `MOVE_BLK_VARIANT` - check `subFunctionStatus` code

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
03.07.2018First released version
03.00.00Simatic Systems Support
09.04.2021Refactoring and alignment to Datatype Variant
Insert documentation