Siemens SIMATIC S7-200 System Manual page 202

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

Advertisement

S7-200 Programmable Controller System Manual
Example: Find String Within String Instruction
The following example uses a string stored at VB0 as a command for turning a pump on or off. A string 'On' is
stored at VB20, and a string 'Off' is stored at VB30. The result of the Find String Within String instruction is
stored in AC0 (the OUT parameter). If the result is not 0, then the string 'On' was found in the command string
(VB12).
VB20
If the string in VB20
is found:
Example: Find Character Within String Instruction
In the following example, a string stored at VB0 contains the temperature. The string at VB20 stores all the
numeric characters (and the + and - -) that can identify a temperature in a string. The sample program finds the
starting position for a number in that string and then converts the numeric characters into a real number.
VD200 stores the real-number value of the temperature.
VB20
Starting position of the temperature
stored in VB0:
188
VB0
12
'T'
'u'
'r'
'n'
VB22
VB30
2
'O'
'n'
AC0
11
VB0
11
'T'
'e'
'm'
'p'
12
'1'
'2'
'3'
'4'
AC0
7
Network 1
//1. Set AC0 to 1.
//
(AC0 is used as the OUT parameter.)
//2. Search the string at VB0 for the string
//
at VB20 ('On'), starting at the first
//
position (AC0=1).
LD
I0.0
MOVB
1, AC0
SFND
VB0, VB20, AC0
' '
'P'
'u'
'm'
VB33
3
'O'
'f'
'f'
If the string in VB20
is not found:
Network 1
//1. Set AC0 to 1.
//
(AC0 is used as the OUT parameter
//
and points to the first position of the string.)
//2. Find the numeric character
//
in the string at VB0.
//3. Convert the string to a real number.
LD
I0.0
MOVB
1, AC0
CFND
VB0, VB20, AC0
STR
VB0, AC0, VD200
' '
' '
'9'
'8'
'5'
'6'
'7'
'8'
Real-number value of the
temperature:
VB12
'p'
' '
'O'
'n'
AC0
0
VB11
'.'
'6'
'F'
VB32
'9'
'0'
'+'
'- -'
VD200
98.6

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents