Siemens SIMATIC S7-200 System Manual page 49

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

Advertisement

As shown in Figure 4-13, you can change the value of a pointer. Since pointers are 32-bit values,
use double-word instructions to modify pointer values. Simple mathematical operations, such as
adding or incrementing, can be used to modify pointer values.
V199
V200
1 2
V201
3 4
V202
5 6
7 8
V203
V199
V200
1 2
3 4
V201
V202
5 6
7 8
V203
Figure 4-13
Modifying a Pointer
Tip
Remember to adjust for the size of the data that you are accessing: to access a byte, increment
the pointer value by 1; to access a word or a current value for a timer or counter, add or
increment the pointer value by 2; and to access a double word, add or increment the pointer
value by 4.
Sample Program for Using an Offset to Access Data in V Memory
This example uses LD10 as a pointer to the address VB0. You then increment the pointer by an offset stored in VD1004.
LD10 then points to another address in V memory (VB0 + offset). The value stored in the V memory address pointed to
by LD10 is then copied to VB1900. By changing the value in VD1004, you can access any V memory location.
AC1
address of VW200
AC0
1 2 3 4
AC1
address of VW202
AC0
5 6 7 8
Network 1 //How to use an offset to read the value
//of any VB location:
//
//1. Load the starting address of the
//V memory to a pointer.
//2. Add the offset value to the pointer.
//3. Copy the value from the V memory
//location (offset) to VB1900.
//
LD
SM0.0
MOVD &VB0, LD10
+D
VD1004, LD10
MOVB *LD10, VB1900
PLC Concepts
MOVD &VW200, AC1
Creates the pointer by moving the address of
VB200 (address of VW200's initial byte) to AC1.
MOVW *AC1, AC0
Moves the word value pointed to by
AC1 (VW200) to AC0.
+D +2, AC1
Adds 2 to the accumulator to point to the
next word location.
MOVW *AC1, AC0
Moves the word value pointed to by
AC1 (VW202) to AC0.
Chapter 4
35

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents