Page 285 - Programmable Logic Controllers, Fifth Edition - Mobile version
P. 285
1 0 1 1 0 0 1 0 1 1 1 0 1 0 0 1
Original data in initial position
Data in = 1
1 1 0 1 1 0 0 1 0 1 1 1 0 1 0 0
New data in shift right position
Shift data
(clock)
Data in = 0
0 1 1 0 1 1 0 0 1 0 1 1 1 0 1 0 Tracking the absence of bottles
New data in shift right position
Shift data
(clock)
Figure 12-21 Basic concept of a shift register.
Source: Photo courtesy Omron Industrial Automation, www.ia.omron.com.
working with any bit in the register becomes a mat- Shift registers are useful for tracking the status or iden-
ter of identifying the position it occupies rather than tification of a part as it moves down an assembly line.
the conventional word number/bit number addressing The data file used for a shift register usually is the bit file
scheme. because its data are displayed in binary format, making it
Figure 12-23 shows the File Shift menu tab and BSL easier to read. BSL and BSR are output instructions that
and BSR instruction blocks that are part of the instruction load data into a bit array one bit at a time. The data are
set for the Allen-Bradley SLC 500 controllers. The com- shifted through the array, then unloaded one bit at a time.
mands can be summarized as follows: The BSL instruction has the same operands as the BSR
instruction. The difference is the direction in which the
BSL (Bit Shift Left)—Loads a bit of data into a
bit array, shifts the pattern of data through the array bits are indexed. A bit shift instruction will execute when
to the left, and unloads the last bit of data in the its input control logic goes from false to true. To program
array. a bit shift instruction, you need to provide the processor
with the following information:
BSR (Bit Shift Right)—Loads a bit of data into a bit
array, shifts the pattern of data through the array to the File—The address of the bit array you want to manip-
right, and unloads the last bit of data in the array. ulate. The address must start with the # sign and at bit
0 of the first word or element. Any remaining bits in
the last word of the array cannot be used elsewhere in
Most significant the program because the instruction invalidates them.
bit address Control—R data-table type. The address is unique to
the instruction and cannot be used to control any other
1 or 0 instruction. It is a three-word element that consists of
Bit shift right (BSR) register the status word, the length, and the position.
Least significant
bit address
BSL BSR SQC SQL SQO FFL FFU LFL LFU
1 or 0
File/Misc File Shift / Sequencer Program Control
Bit shift left (BSL) register
BSL BSR
BIT SHIFT LEFT EN BIT SHIFT RIGHT EN
File File
Control DN Control DN
Bit address Bit address
Length Length
Wraparound or circulating shift register
Figure 12-22 Types of shift registers. Figure 12-23 Bit shift left and bit shift right instructions.
266 Chapter 12 Sequencer and Shift Register Instructions
pet73842_ch12_252-280.indd 266 03/11/15 7:20 PM