BSL (bit shift left)
The BSL instruction shifts a bit in an array element to the left.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the L20E, L50E, and L70E controllers.
Operation details:
The BSL instruction is an immediate process on false-to-true rung transition and updates output synchronously. When Execute is TRUE, the leftmost bit (Src + SrcOffset and Length) is copied into the Unload bit and all bits in the array or non-array are shifted left by one bit. Length and 16 bit boundary are considered except for BOOL data types. The external bit is then moved to bit 0 (Src + SrcOffset) of the first element.
For wraparound operations, set the position of the BitAddr to the last bit position or to the Unload bit. A possible usage of the BSL instruction is tracking bottles through a bottling line, where each bit represents a bottle.
BSL

Parameter | Parameter Type | Data Type | Description |
---|---|---|---|
Execute | Input | BOOL | Instruction enable.
|
Scr | Input | ANY_ELEMENTARY | The address of the Src (bit) to be shifted. Supported data types: BOOL, DWORD, INT, UINT, WORD, DINT and UDINT.
|
SrcOffset | Input | UINT | If SrcOffset is 0, start from the first element.
|
BitAddr | Input | BOOL | Location of the bit shifted into Src. |
Length | Input | UINT | Length contains the number of bits in the Src to be shifted. Supports shifting across array elements.
|
Unload | Output | BOOL | Bit shifted out from Src address. |
Error | Output | BOOL | When a fault occurs, Error is set to true. |
ErrorID | Output | USINT | When a fault occurs, ErrorID contains the error code. |
Done | Output | BOOL | When TRUE, operation completed successfully. When FALSE, operation encountered an error condition. |
Error code | Error description |
---|---|
01 | Dimension not supported. |
02 | Data type not supported. |
03 | Length of bits exceeds 2048. |
04 | Source offset exceeds the size of the array. |
05 | Length of bits exceeds the size of the array. |
07 | Invalid parameters. |
BSL examples
BSL function block diagram example

BSL ladder diagram example

BSL structured text example

Results

Provide Feedback