Bit Shift Right (BSR)

This table lists the controllers and applications that support this instruction.
Architecture
Standard applications
Safety applications
CompactLogix 5370, ControlLogix 5570, Compact GuardLogix 5370, and GuardLogix 5570 controllers
Yes
No
CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers
Yes
Yes
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
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)
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
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
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.