CONVERT: Convert value (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
CONVERT: Convert value

Description

The "Convert value" instruction reads the content of the IN parameter and converts it according to the data types set in the instruction box. The converted value is output at the OUT output.

The enable output ENO has the signal state "0" if one of the following conditions applies:

  • The EN enable input has the signal state "0".

  • Errors, such as an overflow, occur during execution.

Conversion options for bit strings

The bit strings BYTE and WORD cannot be selected in the instruction box. However, it is possible to specify an operand of data type DWORD or LWORD at a parameter of the instruction if the lengths of the input and output operands match. The operand will be interpreted and implicitly converted from the data type of a bit string according to the data type of the input or output parameter. The data type DWORD is for example interpreted as DINT/UDINT and LWORD as LINT/ULINT. These conversion options are also available to you when "IEC check" is enabled.

Note

For CPUs of the S7-1500 series: The data types DWORD and LWORD can only be converted to or from data type REAL or LREAL.

During the conversion, the bit pattern of the source value is transferred unchanged, right-justified, to the target data type. If no errors occur during the conversion, the signal state of enable output ENO = 1; if an error occurs during processing, the signal state of the enable output ENO = 0.

Parameters

The following table shows the parameters of the "Convert value" instruction:

Parameters

Declaration

Data type

Memory area

Description

S7-1200

S7-1500

EN

Input

BOOL

I, Q, M, D, L or constant

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

Enable input

ENO

Output

BOOL

I, Q, M, D, L

I, Q, M, D, L

Enable output

IN

Input

Bit strings, integers, floating-point numbers, CHAR, WCHAR, BCD16, BCD32

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

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

Value to be converted.

OUT

Output

Bit strings, integers, floating-point numbers, CHAR, WCHAR, BCD16, BCD32

I, Q, M, D, L, P

I, Q, M, D, L, P

Result of the conversion

You can select the data types of the instruction from the "???" drop-down lists of the instruction box.

Example

The following example shows conversion of an integer (16 bit) to another integer (32 bit):

The following example shows conversion of a byte (8 bit) to the integer SINT (8 bit):

The following example shows the conversion of a byte (8 bit) to the unsigned integer USINT (8 bit):

The conversions are possible, because the length of the two operands is the same.