Basic instructions
8.7 Conversion operations
S7-1200 Programmable controller
294 System Manual, V4.2, 09/2016, A5E02486680-AK
Table 8- 111 Conversion from a Char or String
Char
CHAR_TO_SINT, CHAR_TO_USINT,
CHAR_TO_INT, CHAR_TO_UINT,
CHAR_TO_DINT, CHAR_TO_UDINT
The value is converted.
The value is transferred to the first character of
the string.
String
STRING_TO_SINT, STRING_TO_USINT,
STRING_TO_INT, STRING_TO_UINT,
STRING_TO_DINT, STRING_TO_UDINT,
STRING_TO_REAL, STRING_TO_LREAL
The value is converted.
The first character of the string is copied to the
ROUND (Round numerical value) and TRUNC (Truncate numerical value)
Table 8- 112 ROUND and TRUNC instructions
Converts a real number to an integer. For LAD/FBD, you click the "???" in
the instruction box to select the data type for the output, for example "DInt".
For SCL, the default data type for the output of the ROUND instruction is
DINT. To round to another output data type, enter the instruction name with
the explicit name of the data type, for example, ROUND_REAL or
ROUND_LREAL.
The real number fraction is rounded to the nearest integer value (IEEE -
round to nearest). If the number is exactly one-half the span between two
integers (for example, 10.5), then the number is rounded to the even inte-
ger. For example:
• ROUND (10.5) = 10
• ROUND (11.5) = 12
TRUNC converts a real number to an integer. The fractional part of the real
number is truncated to zero (IEEE - round to zero).
1
For LAD and FBD: Click the "???" (by the instruction name) and select a data type from the drop-down menu.
Table 8- 113 Data types for the parameters
SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
Rounded or truncated output