Bit Shift Right (BSR)

The BSR instruction shifts the specified bits within the Array one position right. When enabled, the instruction unloads the value at bit 0 of Array to the .UL bit, shifts the remaining bits one position right, and loads the bit from the Bit address.
IMPORTANT: Test and confirm that the instruction changed the correct data. The BSR instruction operates on continuous memory. If an Array is a member array, the instruction may shift beyond the boundary of the array into other members following it. Be sure to carefully select a length that does cause this scenario to occur.
The BSR instruction operates on contiguous data memory.
If the instruction tries to read past the end of an array (the LEN is too big), the instruction sets the .ER bit and generates a major fault.
Available Languages
Ladder Diagram
Ladder Diagram_Bit Shift Right (BSR)_v1
Operands
There are data conversion rules for mixed data types within an instruction. See Data Conversion.
Ladder Diagram
Operand
Data Type
Format
Description
Array
DINT ARRAY
tag
Array to modify
specify the first element to be shifted.
Control
CONTROL
tag
Control structure for the operation
Source Bit
BOOL
tag
Bit to load into the vacated position.
Length
DINT
immediate
Number of bits in the array to shift
CONTROL Structure
Mnemonic
Data Type
Description
.EN
BOOL
The enable bit indicates the BSR instruction is enabled.
.DN
BOOL
The done bit is set to indicate that bits shifted one position to the right.
.UL
BOOL
The unload bit is the instruction’s output. The .UL bit stores the status of the bit that was shifted out of the range of bits.
.ER
BOOL
The error bit is set when .LEN < 0.
.LEN
DINT
The length specifies the number of array bits to shift.
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See Index through arrays for array-indexing faults.
Execution
Ladder Diagram
Condition/State
Action Taken
Prescan
The .EN bit is cleared to false.
The .DN bit is cleared to false.
The .ER bit is cleared to false.
The .POS value is cleared.
Rung-condition-in is false
The .EN bit is cleared to false.
The .DN bit is cleared to false.
The .ER bit is cleared to false.
The .POS value is cleared.
Rung-condition-in is true
See the following BSR Flow Chart (True)
Postscan
N/A
BSR Flow Chart (True)
RSL5K_BSR Flow Chart
Examples
Example 1
When enabled, the BSR instruction copies array_dint[0].0 to the .UL bit, shifts 0-9 to the right, and loads the input_1 into array_dint[0].9. The remaining bits (10-31) are invalid, which indicates the bits may not be modified.
Ladder Diagram
FTStudio-BSR-LD-EX1-V1
RSL5K_BSR array_dint before and after shift
Example 2
When enabled, the BSR instruction copies array_dint[0].0 to the .UL bit, shifts 0-9 to the right, and loads the input_1 into array_dint[1].25.. The remaining bits (31-26 in dint_array[1]) are invalid, which indicates that the bits may not be modified. Note how array_dint[1].0 shifts across words into array_dint[0].31.
Ladder Diagram
FTStudio-BSR-LD-EX2-V1
RSL5K_BSR array_dint 0 and 1
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.