You are on page 1of 2

Siemens - Industry Automation and Drive Technologies - Service& Support - Automation...

Page 1 of 2
show the entry list Creating a table in an S7-200 QUESTION: How can I configure a table in an S7-200 project and what should I watch out for? ANSWER: A table in an S7-200 is like the one shown below: Memory location VW0 VW2 VW4 VW6 VW... VW44 Content 0020 0005 Entry 1 Entry 2 Entry ... Entry 20 Description Maximum number of table entries Actual number of table entries Content of VW4 Content of VW6 Content of VW... Content of VW44

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. What it does not include are the parameters defining the maximum length of the table and the actual number of entries (here VW0 and VW2). The following program creates a table with 20 entries. It begins with location 4 and is controlled with inputs I0.0 to I0.3: NETWORK 1 // Network 1 Create table with 20 entries starting with memory location 4 LD SM0.1 // Load special marker bit 1 MOVW +20, VW0 // Define length of table NETWORK 2 // Network 2 Reset table with input I0.0 LD I0.0 // Load input I0.0 EU // Edge test FILL +0, VW2, 21 // Fill memory locations from VW2 with "+0" NETWORK 3 // Network 3 Write value to table with input I0.1 LD I0.1 // Load input I0.1 EU // Edge test ATT VW100, VW0 // Write value of memory location 100 to table NETWORK 4 // Network 4 Read first table value with input I0.2 LD I0.2 // Load input I0.2 EU // Edge test LIFO VW0, VW102 // Write last table value to memory location 102 NETWORK 5 // Network 5 Read last table value with input I0.3 LD I0.3 // Load input I0.3 EU // Edge test FIFO VW0, VW104 // Write first table value to memory location 104 In the first network the table is created using the command "MOVW +20, VW0". In Network 2 the whole table is reset according to an edge at input I0.0. The "FILL +0, VW2, 20" command used fills the storage area from VW2 to VW40 with the value "+0". In the third network the command "ATT VW100, VW0", controlled by an edge at input I0.1, writes the value of location 100 to the table. The 10.09.2010

Siemens - Industry Automation and Drive Technologies - Service& Support - Automation... Page 2 of 2
command "LIFO VW0, VW102" in Network 4 shifts the last table value to location 102. This reduces the number of entries. Alternatively the command "FIFO VW0, VW104" writes the first entry in the table to location 104. All the following entries move one place up. The actual number of entries in the table (here VW2) is automatically incremented or decremented by the CPU with every command. Detailed descriptions of the commands used are given in the online Help for STEP7 MICRO. For more information on handling tables, please refer to the manual for S7-21x CPU's ( Entry ID: 1109154 ) from page 10-73 and the manual for S7-22x CPU's ( Entry ID : 1109582 ) from page 9-107. Note : Don't forget whenever you want to work with a table, first make an entry for the "maximum number of table entries". If you don't do this, you cannot make entries in the table at all. In addition, you must watch out with all read and write commands that they are activated with edges. Keywords: Programming note, Stack memory

Entry ID:9173468 Date:2001-11-14 I regard this article.... Copy link

Print Siemens AG 2010 - Corporate Information - Privacy Policy - Terms of Use

as helpful

as not helpful Send to a friend

Suggestion for the entry 10.09.2010