Program instructions
7.5 Convert
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
211
Real to string conversion
The Real to String instruction converts a real value IN to an ASCII string.
The format (FMT) assigns the conversion precision to the right of the deci-
mal, whether the decimal point is to be shown as a comma or a period and
the length of the output string. The resulting conversion is placed in a string
beginning with OUT. The length of the resulting string is specified in the
format and can be 3 to 15 characters.
Non-fatal error conditions with ENO = 0
• 0006H indirect address
• 0091H operand out of range
• Illegal format
– (nnn > 5)
– ssss < 3
– ssss < number of characters required
None
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC, Constant
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
The real-number format used by the CPU supports a maximum of 7 significant digits. An
attempt to display more than the 7 significant digits produces a rounding error.
The length of the output string is specified by the ssss field. A size of 0, 1, or 2 bytes is not
valid. The number of digits to the right of the decimal point in the output buffer is assigned by
the nnn field. The valid range of the nnn field is 0 to 5. If you assign 0 digits to the right of the
decimal point, then the value is displayed without a decimal point. The output string is filled
with ASCII space characters when nnn is greater than 5 or when the assigned length of the
output string is too small to store the converted value. The c bit specifies the use of either a
comma (c=1) or a decimal point (c=0) as the separator between the whole number and the
fraction.
The following figure also shows examples of values that are formatted using a decimal point
(c= 0) with one digit to the right of the decimal point (nnn = 001) and an output string length
of 6 characters (ssss = 0110). The value at OUT is the length of the string stored in the next
byte addresses.