Detailed description
2.14 Programming tips with STEP 7
Basic logic functions: PLC basic program solution line (P3 sl)
260
Function Manual, 11/2006, 6FC5397-0BP10-2BA0
Note
When complex programs are implemented in multiinstance 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 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 FB 99
Comment
VAR_INPUT
varin: INT ;
END_VAR
VAR
variable1: ARRAY[0 to 9] of INT;
variable2: INT ;
END_VAR
BEGIN
L
P##variable1;
//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.
AD
DW#16#00FF_FFFF,
//Skipping of an area
LAR1
//Load into AR1
TAR2;
+AR1 AR2;
//AR2 instance offset to be added
//The ARRAY of variable1 can now be accessed indirectly via AR1.
L
DIW [AR1, P#0.0];
//E.g., access to first element
END_FUNCTION_BLOCK
Summary of Contents for SINUMERIK 840D sl
Page 282: ...Index Basic logic functions Acceleration B2 64 Function Manual 11 2006 6FC5397 0BP10 2BA0 ...
Page 388: ...Basic logic functions Travel to fixed stop F1 Function Manual 11 2006 6FC5397 0BP10 2BA0 52 ...
Page 962: ...Index Basic logic functions Emergency Stop N2 20 Function Manual 11 2006 6FC5397 0BP10 2BA0 ...
Page 1704: ...Constraints Basic logic functions Spindles S1 94 Function Manual 11 2006 6FC5397 0BP10 2BA0 ...
Page 1716: ...Index Basic logic functions Spindles S1 106 Function Manual 11 2006 6FC5397 0BP10 2BA0 ...
Page 1996: ...Index Basic logic functions Tool Offset W1 208 Function Manual 11 2006 6FC5397 0BP10 2BA0 ...
Page 2150: ...Table of contents Basic logic functions Appendix 4 Function Manual 11 2006 6FC5397 0BP10 2BA0 ...
Page 2184: ...Glossary Basic logic functions Appendix 38 Function Manual 11 2006 6FC5397 0BP10 2BA0 ...