Siemens SIMATIC S7-200 System Manual page 123

Programmable controller
Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

Operation of the Real to String
The Real to String instruction (RTS) converts a real value IN
to an ASCII string. The format (FMT) specifies the
conversion precision to the right of the decimal, 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. For more information,
see the section that describes the format for strings in
Chapter 4.
The real-number format used by the S7-200 supports a maximum of 7 significant digits.
Attempting to display more than the 7 significant digits produces a rounding error.
Figure 6-20 describes the format operand for the Real to String instruction. 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 specified by 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 string is filled with ASCII space characters
when nnn is greater than 5 or when the specified 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.
Figure 6-20 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 a output string length of 6 characters
(ssss = 0110). The value at OUT is the length of the string. The output string is formatted
according to the following rules:
Positive values are written to the output buffer without a sign.
-
Negative values are written to the output buffer with a leading minus sign (--).
-
Leading zeros to the left of the decimal point (except the digit adjacent to the decimal point)
-
are suppressed.
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.
The size of the output string must be a minimum of three bytes more than the number of
-
digits to the right of the decimal point.
Values are right-justified in the output string.
-
FMT
MSB
7
6
5
4
3
2
1
s
s
s
s
c
n
n
ssss = length of output string
c = comma (1) or decimal point (0)
nnn = digits to right of decimal point
Figure 6-20
FMT Operand for the Real to String Instruction
LSB
0
n
S7-200 Instruction Set
Error conditions that set ENO = 0
H 0006 (indirect address)
H 0091 (operand out of range)
H Illegal format:
nnn > 5
ssss < 3
ssss < number of characters
required
Out
Out Out Out
+1
+2
in=1234.5
6
1
2
in= - -0.0004
6
in= - -3.67526
6
in = 1.95
6
Chapter 6
Out
Out
Out
+3
+4
+5
+6
3
4
.
5
0
.
.
0
- -
3
.
7
.
2
0
109

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents