Siemens SINUMERIK 840Di Function Manual page 1175

Basic machine
Hide thumbs Also See for SINUMERIK 840Di:
Table of Contents

Advertisement

Note
For more complex programs using pointers and address registers in FBs, which are to be
multi-instance capable, certain rules specified by the programmer must be complied with.
With multi-instance DBs, the start address of the variable (VAR_INPUT, VAR_OUTPUT,
VAR_IN_OUT, VAR) is transferred with the DI data block register and address register AR2.
When variables are accessed within the multi-instance FB, the compiler independently
controls the access operation via address register AR2. However, when complex program
sections also have to work with address registers in the same FB (e.g., to copy data), then
the old contents of AR2 must be saved before the register is changed. The contents of AR2
must be restored to their original state before an instance variable (VAR_INPUT,
VAR_OUTPUT, VAR_IN_OUT, VAR) is accessed. It is best to save the AR2 register of the
instance in a local variable (VAR_TEMP).
The 'load pointer to an instance variable' command returns a pointer value at the start of the
instance data. To be able to access this variable via a pointer, the offset stored in AR2 must
be added.
Example
FUNCTION_BLOCK FB 99
VAR_INPUT
varin: INT ;
END_VAR
VAR
variable1: ARRAY[0 to 9] of INT;
variable2: INT ;
END_VAR
BEGIN
L
P##variable1;
AD
DW#16#00FF_FFFF,
LAR1
TAR2;
+AR1 AR2;
L
DIW [AR1, P#0.0];
END_FUNCTION_BLOCK
Power Line Basic PLC Program (P3)
Function Manual, 08/2005 Edition, 6FC5397-0BP10-0BA0
Comment
//Pointer at start of ARRAY
//The value 8500 0010 is now in the accumulator
//and a cross-area pointer is in the AR2. If cross-area
processing is to take place, then an area should be skipped
when these two pointers are added.
//Skipping of an area
//Load into AR1
//AR2 instance offset to be added
//The ARRAY of variable1 can now be accessed indirectly via
AR1.
//E.g., access to first element
2.14 Useful tips on programming with STEP 7
Detailed description
2-263

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents