Siemens SINUMERIK 840D sl Function Manual page 1073

Hide thumbs Also See for SINUMERIK 840D sl:
Table of Contents

Advertisement

Multi-instance DBs should be activated only when they are actually going to be used since
they increase the runtime and code size of the FBs.
Note
When complex programs are implemented in multiinstance enabled FBs that use a pointer
and address register, it is important for the programmer to observe certain rules.
With multiinstance 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 multiinstance enabled 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. The AR2 register of the instance is to be saved most usefully
in a local variable (VAR_TEMP).
The command "Load pointer to an instance variable" returns a pointer value from 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 FB99
VAR_INPUT
END_VAR
VAR
END_VAR
BEGIN
L
AD
LAR1
TAR2;
+AR1 AR2;
L
END_FUNCTION_BLOCK
Basic Functions
Function Manual, 01/2015, 6FC5397-0BP40-5BA2
varin: INT;
variable1: ARRAY[[0..9]
of INT;
variable2: INT;
P##variable1;
DW#16#00FF_FFFF, //Skipping of an area
DIW [AR1, P#0.0];//E.g. access to the first element
P3: Basic PLC program for SINUMERIK 840D sl
13.19 Programming tips with STEP 7
//Pointer at start of ARRAY
//The value 8500 0010 is now in the accumulator
//and a cross-area pointer is in the AR2
//Pointer. If one is to work across areas
//then, during the addition of these
//two pointers, an area is to be disabled.
//Load into AR1
//AR2 instance offset to be added
//You can now indirectly access the ARRAY
//of variable 1 via AR1.
1073

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sinumerik 828dSinumerik 840de sl

Table of Contents