SHL: Shift 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
SHL: Shift left

Description

You can use the "Shift left" instruction to shift 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 moved.

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

If the value at the input N is greater than the number of available bit positions, the operand value at input IN is shifted to the left by the available number of bit positions.

The bit positions in the right part of the operand freed by shifting are filled with zeros.

The following figure shows how the content of an operand of the WORD data type is shifted by six bit positions to the left:

Parameters

The following table shows the parameters of the instruction "Shift 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 shifted.

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 shifted.

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

0011 1111 1010 1111

N

Tag_Number

4

OUT

TagOut_Value

1111 1010 1111 0000

If the "TagIn" operand has signal state "1", the instruction is executed. The content of the operand "TagIn_Value" is shifted four 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.