PLC concepts
4.2 Accessing data
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
87
4.2.7
Pointer examples
Using a pointer to access data in a table
This example uses LD14 as a pointer to a recipe stored in a table of recipes that begins at
VB100. In this example, VW1008 stores the index to a specific recipe in the table. If each
recipe in the table is 50 bytes long, you multiply the index by 50 to obtain the offset for the
starting address of a specific recipe. By adding the offset to the pointer, you can access the
individual recipe from the table. In this example, the recipe is copied to the 50 bytes that start
at VB1500.
Table 4- 19 Example: Using a pointer to access data in a table
LAD
STL
To transfer a recipe from a table of
recipes:
•
Each recipe is 50 bytes long.
•
The index parameter (VW1008)
identifies the recipe to be loaded.
Create a pointer to the starting address
of the recipe table.
Convert the index of the recipe to a
double-word value.
Multiply the offset to accommodate the
size of each recipe.
Add the adjusted offset to the pointer.
Transfer the selected recipe to VB1500
through VB1549
Network 1
LD SM0.0
MOVD &VB100, LD14
ITD VW1008, LD18
*D +50, LD18
+D LD18, LD14
BMB *LD14, VB1500, 50