SWAP: Swap (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
SWAP: Swap

Description

You can use the instruction "Swap" to change the order of the bytes within the tag at input IN and query the result at output OUT.

The following figure shows how the bytes of a DWORD data type operand are swapped using the "Swap" instruction:

Parameters

The following table shows the parameters of the "Swap" instruction:

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

WORD, DWORD

WORD, DWORD, LWORD

I, Q, M, D, L, P or constant

I, Q, M, D, L, P or constant

Operand whose bytes are swapped.

OUT

Output

WORD, DWORD

WORD, DWORD, LWORD

I, Q, M, D, L, P

I, Q, M, D, L, P

Result

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

0000 1111 0101 0101

OUT

TagOut_Value

0101 0101 0000 1111

If the "TagIn" operand has signal state "1", the instruction is executed. The arrangement of the bytes is changed and stored in the operand "TagOut_Value".