Shift And Rotate Instructions - Siemens Simatic S7-200 System Manual

Programmable controller
Hide thumbs Also See for Simatic S7-200:
Table of Contents

Advertisement

Instruction Set

10.9 Shift and Rotate Instructions

Shift Register Bit
L
A
D
EN
DATA
S_BIT
N
S
T
SHRB DATA, S_BIT, N
L
212
214
Understanding the Shift Register Bit Instruction
The Shift Register Bit instruction provides an easy method for the sequencing and controlling
of product flow or data. Use the Shift Register Bit instruction to shift the entire register one bit,
once per scan. The Shift Register Bit instruction is defined by both the least significant bit
(S_BIT) and the number of bits specified by the length (N). Figure 10-32 shows an example
of the Shift Register Bit instruction.
The address of the most significant bit of the Shift Register (MSB.b) can be computed by the
following equation:
MSB.b = [(Byte of S_BIT) + ([N] - 1 + (bit of S_BIT)) / 8] . [remainder of the division by 8]
You must subtract 1 bit because S_BIT is one of the bits of the Shift Register.
For example, if S_BIT is V33.4, and N is 14, then the MSB.b is V35.1, or:
MSB.b
= V33 + ([14] - 1 +4)/8
= V33 + 17/8
= V33 + 2 with a remainder of 1
= V35.1
On a Shift Minus, indicated by a negative value of length (N), the input data shifts into the
most significant bit of the Shift Register, and shifts out of the least significant bit (S_BIT).
On a Shift Plus, indicated by a positive value of length (N), the input data (DATA) shifts into
the least significant bit of the Shift Register, specified by the S_BIT, and out of the most
significant bit of the Shift Register.
The data shifted out is then placed in the overflow memory bit (SM1.1). The maximum length
of the shift register is 64 bits, positive or negative. Figure 10-31 shows bit shifting for negative
and positive values of N.
10-78
The Shift Register Bit instruction shifts the value of DATA into
the Shift Register. S_BIT specifies the least significant bit of the
SHRB
Shift Register. N specifies the length of the Shift Register and
the direction of the shift (Shift Plus = N, Shift Minus = -N).
Operands:
215
216
DATA, S_BIT: I, Q, M, SM, T, C, V, S
N:
VB, IB, QB, MB, SMB, AC,
Constant, *VD, *AC, SB
S7-200 Programmable Controller System Manual
C79000-G7076-C230-02

Advertisement

Table of Contents
loading

Table of Contents