ROL: Rotate left (S7-1200, S7-1500) - STEP 7

FBD (S7-1200, S7-1500)

ft:publication_title
FBD (S7-1200, S7-1500)
Product
STEP 7
Version
V20
Publication date
11/2024
Language
en-US
ROL: Rotate left

Description

You can use the "Rotate left" instruction to rotate the content of the operand at the input IN bit-by-bit to the left and query the result at the OUT output. The input N is used to specify the number of bit positions by which the specified value should be rotated. The bit positions freed by rotating on the right-hand side are filled true-to-position with the bit positions that are pushed out from the left-hand side.

If the value at the input N is "0", the value at input IN is copied to the operand at output OUT.

If the value of the N parameter is greater than the number of available bit positions, the operand value at the IN input is nevertheless rotated by the specified number of bit positions.

The following figure shows how the content of an operand of the DWORD data type is rotated three bit positions to the left:

Parameters

The following table shows the parameters of the instruction "Rotate left":

Parameters

Declaration

Data type

Memory area

Description

S7-1200

S7-1500

S7-1200

S7-1500

EN

Input

BOOL

BOOL

I, Q, M, D, L or constant

I, Q, M, D, L, T, C or constant

Enable input

ENO

Output

BOOL

BOOL

I, Q, M, D, L

I, Q, M, D, L

Enable output

IN

Input

Bit strings, integers

Bit strings, integers

I, Q, M, D, L or constant

I, Q, M, D, L or constant

Value to be rotated.

N

Input

USINT, UINT, UDINT

USINT, UINT, UDINT, ULINT

I, Q, M, D, L or constant

I, Q, M, D, L or constant

Number of bit positions by which the value is rotated.

OUT

Output

Bit strings, integers

Bit strings, integers

I, Q, M, D, L

I, Q, M, D, L

Result of the instruction

You can select the data type of the instruction from the "???" drop-down list of the instruction box.

For additional information on valid data types, refer to "See also".

Example

The following example shows how the instruction works:

The following table shows how the instruction works using concrete operand values:

Parameters

Operand

Value

IN

TagIn_Value

1010 1000 1111 0110

N

Tag_Number

5

OUT

TagOut_Value

0001 1110 1101 0101

If the "TagIn" has the signal state "1", the instruction is executed. The content of the operand "TagIn_Value" is rotated five bit positions to the left. The result is output at the "TagOut_Value" output. If the instruction is executed without errors, the ENO enable output has the signal state "1" and the "TagOut" output is set.