BSR (bit shift right)
The BSR instruction shifts a bit in an array element to the right.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the L20E, L50E, and L70E controllers.
Operation details:
The BSR instruction is an immediate process on false-to-true rung transition and updates output synchronously. When Execute is TRUE, the right most bit (bit 0 of the element addressed by Src + SrcOffset) is copied into the Unload bit and all bits in the array or non-array are shifted right 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.
BSR

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 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. |
BSR examples
BSR function block diagram example

BSR ladder diagram example

BSR structured text example

Results

Provide Feedback