Siemens SIMATIC S7-200 System Manual page 124

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

Advertisement

S7-200 Programmable Controller System Manual
Converting Substrings to Numerical Values
The Substring to Integer (STI), Substring to Double Integer
(STD), and Substring to Real (STR) instructions convert a
string value IN, starting at the offset INDX, to an integer,
double integer or real number value OUT
Error conditions that set ENO = 0
H 0006 (indirect address)
H 0091 (operand out of range)
H 009B (index = 0)
H SM1.1 (overflow)
The Substring to Integer and Substring to Double Integer
convert strings with the following form:
[spaces] [+ or --] [digits 0 -- 9]
The Substring to Real instruction converts strings with the
following form:
0 -- 9]
The INDX value is normally set to 1, which starts the
conversion with the first character of the string. The INDX
value can be set to other values to start the conversion at
different points within the string. This can be used when the
input string contains text that is not part of the number to be
converted. For example, if the input string is "Temperature:
77.8", you set INDX to a value of 13 to skip over the word
"Temperature: " at the start of the string.
The Substring to Real instruction does not convert strings
using scientific notation or exponential forms of real
numbers. The instruction does not produce an overflow
error (SM1.1) but converts the string to a real number up to
the exponential and then terminates the conversion. For
example, the string '1.234E6' converts without errors to a
real value of 1.234.
The conversion is terminated when the end of the string is reached or when the first invalid
character is found. An invalid character is any character which is not a digit (0 -- 9).
The overflow error (SM1.1) is set whenever the conversion produces an integer value that is too
large for the output value. For example, the Substring to Integer instruction sets the overflow error
if the input string produces a value greater than 32767 or less than --32768.
The overflow error (SM1.1) is also set if no conversion is possible when the input string does not
contain a valid value. For example, if the input string contains 'A123', the conversion instruction
sets SM1.1 (overflow) and the output value remains unchanged.
Table 6-20
Valid Operands for the Instructions That Convert Substrings to Numerical Values
Inputs/Outputs
IN
INDX
OUT
110
[spaces] [+ or --] [digits 0 -- 9] [. or ,] [digits
Data Type
Operands
STRING
IB, QB, VB, MB, SMB, SB, LB, *VD, *LD, *AC, Constant
BYTE
VB, IB, QB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
INT
VW, IW, QW, MW, SMW, SW, T, C, LW, AC, AQW, *VD, *LD, *AC
DINT, REAL
VD, ID, QD, MD, SMD, SD, LD, AC, *VD, *LD, *AC
.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents