|IN||VD, ID, QD, MD, SD, SMD, LD, AC, Constant, *VD, *AC, *LD||REAL|
|FMT||VB, IB, QB, MB, SMB, LB, AC, Constant, *VD, *AC, SB, *LD||BYTE|
|OUT||VB, IB, QB, MB, SMB, LB, *VD, *AC, SB, *LD||BYTE|
|Memory Ranges||ENO||Errors||Instruction Support for S7-200 CPUs||SIMATIC/International Mnemonics|
|The Real to ASCII instruction converts floating point value (IN) to an ASCII string. The format (FMT) specifies the conversion precision to the right of the decimal, and whether the decimal point is shown as a comma or a period, and the output buffer size. The resulting conversion is placed in an output buffer beginning with OUT. The length of the resulting ASCII string is the size of the output buffer, and can be specified to a size ranging from 3 to 15 characters.
Error Conditions that Set ENO = 0:
0006 (indirect address), SM4.3 (run-time), no output (illegal format)
The format operand (FMT) for the RTA instruction is defined below. The size of the output buffer 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 specified be the nnn field. The valid range of the nnn field is 0 to 5. Specifying 0 digits to the right of the decimal point causes the value to be displayed without a decimal point. The output buffer is filled with ASCII spaces for values of nnn bigger than 5 or when the specified output buffer 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 output buffer is formatted in accord with the following rules:
1.Positive values are written to the output buffer without the sign.
2.Negative values are written to the output buffer with a leading minus sign (-).
3.Leading zeros to the left of the decimal point (except the digit adjacent to the decimal point) are suppressed.
4.Values to the right of the decimal point are rounded to fit in the specified number of digits to the right of the decimal point.
5.The size of the output buffer must be a minimum of three bytes more than the number of digits to the right of the decimal point.
6.Values are right-justified in the output buffer.
Note: The floating point format used by the S7-200 PLC supports a maximum of 7 significant digits. Attempting to display more than the 7 significant digits produces a rounding error.