256 Chapter 12 Sequencer and Shift Register Instructions
An example of a bit shift left (BSL) instruction pro-
gram is shown in Figure12-24 . The operation of the pro-
gram can be summarized as follows:
• Momentary actuation of limit switch LS causes the
BSL instruction to execute.
• When the rung goes from false to true, the enable
bit is set and the data block is shifted to the left (to a
higher bit number) one bit position.
• The speci ed bit, at sensor bit address I:1/1, is
shifted into the rst bit position, B3:10/0.
• The last bit is shifted out of the array and stored in
the unload bit, R6:0/UL.
to the left, and unloads the last bit of data in the
array.
BSR (Bit Shift Right) —Loads a bit of data into a bit
array, shifts the pattern of data through the array to the
right, and unloads the last bit of data in the array.
Shift registers are useful for tracking the status or iden-
ti cation of a part as it moves down an assembly line. The
data le used for a shift register usually is the bit le be-
cause its data are displayed in binary format, making it eas-
ier to read. BSL and BSR are output instructions that load
data into a bit array one bit at a time. The data are shifted
through the array, then unloaded one bit at a time.
The BSL instruction has the same operands as the BSR
instruction. The difference is the direction in which the
bits are indexed. A bit shift instruction will execute when
its input control logic goes from false to true. To program
a bit shift instruction, you need to provide the processor
with the following information:
File —The address of the bit array you want to manip-
ulate. The address must start with the # sign and at bit
0 of the rst word or element. Any remaining bits in
the last word of the array cannot be used elsewhere in
the program because the instruction invalidates them.
Control —R data-table type. The address is unique to
the instruction and cannot be used to control any other
instruction. It is a three-word element that consists of
the status word, the length, and the position.
Bit address —Is the address of the source bit. The instruc-
tion inserts the status of this bit in either the rst (lowest)
bit position (for the BSL instruction) or the last (highest)
bit position (for the BSR instruction) in the array.
Length —Indicates the number of bits to be shifted,
or the le length, in bits. The status bits of the con-
trol word are the enable, done, error, and unload bits.
Their functions can be summarized as follows:
- Enable Bit (EN) —The enable bit follows the instruc-
tions status and is set to 1 when the instruction is true.
- Done Bit (DN) —The done bit is set to 1 when the
instruction has shifted all bits in the le one posi-
tion. It resets to 0 when the instruction goes false.
- Error Bit (ER) —The error bit is set to 1 when the
instruction has detected an error, which can happen
when a negative number is entered in the length.
- Unload Bit (UL) —The unload bit’s status is con-
trolled by shifting of the last bit of the le into the un-
load bit when the instruction is executed. It is the bit
location into which the status from the last bit in the
le shifts when the instruction goes from false to true.
When the next shift occurs, these data are lost, unless
additional programming is done to retain the data.
Figure 12-24 Bit shift left (BSL) instruction program.
BSL
BIT SHIFT LEFT
File
Control
Bit address
Length
EN
DN
L1
Inputs Ladder logic program
Limit switch
Sensor
LS
LS
Ι:1/1
1
15 0
100110011011000
11
Unload bit
R6:0/UL
B3:10
B3:11
Bit address
Ι:1/1
10
Shift direction
20
1
B3:Table - Before limit switch clock pulse
B3:10/
B3:11/
Invalid
1
15
00110011011000
11
Unload bit
R6:0/UL
B3:10
B3:11
Bit address
Ι:1/1
01
Shift direction
20
1
1
B3:Table - After limit switch clock pulse
315 14 13 12 11 10 7 6 498 2150
B3:10/
B3:11/
Invalid
1
0100110 10 101 0011
1000000 00 000 1001
3
1
1
15
1
0
14
1
0
13
0
0
12
0
0
11
1
0
10
1
0
7
1
0
6
1
0
4
1
0
9
0
0
8
0
0
2
1
0
1
1
0
5
0
0
0
0
0
#B3:10
R6:0
Ι:1/1
20
pet10882_ch12_242-267.indd 256pet10882_ch12_242-267.indd 256 7/27/10 4:33 PM7/27/10 4:33 PM