Siemens Simatic S7-200 System Manual page 207

Hide thumbs Also See for Simatic S7-200:
Table of Contents

Advertisement

Example: Creating a Table
The following program creates a table with 20 entries. The first memory location of the table contains the length of the
table (in this case 20 entries). The second memory location shows the current number of table entries. The other
locations contain the entries. A table can have up to 100 entries. It does not include the parameters defining the
maximum length of the table or the actual number of entries (here VW0 and VW2). The actual number of entries in the
table (here VW2) is automatically incremented or decremented by the CPU with every command.
Before you work with a table, assign the maximum number of table entries. Otherwise, you cannot make entries in the
table. Also, be sure that all read and write commands are activated with edges.
To search the table, the index (VW106) must set to 0 before doing the find. If a match is found, the index will have the
table entry number, but if no match is found, the index will match the current entry count for the table (VW2).
S7-200 Instruction Set
Network 1
//Create table with 20 entries starting with memory
//location 4.
//1. On the first scan, define the maximum length
//of the table.
LD
SM0.1
MOVW
+20, VW0
Network 2
//Reset table with input I0.0
//On the rising edge of I0.0,
//fill memory locations from VW2 with "+0" .
LD
I0.0
EU
FILL
+0, VW2, 21
Network 3
//Write value to table with input I0.1
//On the rising edge of I0.1,
//copy value of memory location VW100 to table.
LD
I0.1
EU
ATT
VW100, VW0
Network 4
//Read first table value with input I0.2
//Move the last table value to location VW102.
//This reduces the number of entries.
//On the rising edge of I0.2,
//Move last table value to VW102
LD
I0.2
EU
LIFO
VW0, VW102
Network 5
//Read last table value with input I0.3
//Move the first table value to location VW102.
//This reduces the number of entries.
//On the rising edge of I0.0,
//Move first table value to VW104
LD
I0.3
EU
FIFO
VW0, VW104
Network 6
//Search table for the first location that has a
//value of 10.
//1. On the rising edge of I0.4,
//
reset index pointer.
//2. Find a table entry that equals 10.
LD
I0.4
EU
MOVW
+0, VW106
FND=
VW2, +10, VW106
Chapter 6
6
195

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents