100BBasic instructions
7.7 Convert
S7-1200 Programmable controller
204
System Manual, 11/2011, A5E02486680-05
Table 7- 81 Conversion from Time, DTL, TOD or Date
Data type
Instruction
Result
Time
TIME_TO_DINT
The value is transferred to the target data type.
DTL
DTL_TO_DATE, DTL_TO_TOD
The value is converted.
TOD
TOD_TO_UDINT
The value is converted.
Date
DATE_TO_UINT
The value is converted.
Table 7- 82 Conversion from a Char or String
Data type
Instruction
Result
CHAR_TO_SINT, CHAR_TO_USINT,
CHAR_TO_INT, CHAR_TO_UINT,
CHAR_TO_DINT, CHAR_TO_UDINT
The value is converted.
Char
CHAR_TO_STRING
The value is transferred to the first character of
the 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.
String
STRING_TO_CHAR
The first character of the string is copied to the
Char.
7.7.3
Round and truncate instructions
Table 7- 83 ROUND and TRUNC instructions
LAD / FBD
SCL
Description
out := ROUND (in);
Converts a real number to an integer. 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 integer. For example:
ROUND (10.5) = 10
ROUND (11.5) = 12
out := TRUNC(in);
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.