BSL (Bit Shift Left) Ladder Logic Instruction


The BSL instruction is a ladder logic rung output instruction that shifts data in an array one bit to the left every execution.

The instruction loads the value of the source bit into the lowest bit of the array. The length defines the unload bit. The instruction is enabled when the preceding logic is true and disabled otherwise.

When the instruction is enabled the bit pointed to by the length member is placed in the unload bit. For instance if the length is set to 12 the 12th bit in the array will be placed in the unload bit. All bits above 13 are not affected or invalid. After the 12th bit is placed in the unload bit the remaining lower bits are shifted one position to the left. The last step places the Source_Bit value into the least significant bit of the array. Keep in mind all three steps are one rung scan.


The value of bit 12 is place in the UL bit which in this case is 1.




The least significant bits in the array are shifted 12 bits to the left.



Finally the Source Bit is loaded into the 0 bit of the array. The Source Bit is = 1 therefore a one is loaded into the 1st bit of the array.


List of possible arguments

ARRAY:                    Must be an array of type DINT. Example MY_ARRAY[0]
CONTROL:              Must be of type control.
SOURCE BIT:          Must be a tag defined Boolean bit. No constants.
LENGTH:                  Must be a constant. For example a number like 2.


Control Element Members

.EN                  BOOL             On when the instruction is enabled.
.DN                 BOOL             Set upon completion of a bit shift.
.UL                  BOOL             Value of the bit shifted out of the array.
.ER                  BOOL             Set if the length is less than 0.
.LEN               DINT              Length of bits to shift in array. Also points to the unload bit.


Note: Watch the length. If you put a length in that exceeds the size of your array you will copy data into memory allocated to other tags. Be careful.