Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Local Data Stack Seite 1 von 2

Local Data Stack


The L stack saves the following:
z The temporary variables of the local data of blocks
z The start information of the organization blocks
z Information about transferring parameters
z Interim results of the logic in Ladder Logic programs
When you are programming organization blocks, you can declare temporary variables (TEMP) that are only
available when the block is executed and are then overwritten again. Before you access the local data stack
for the first time, the local data must be initialized. In addition to this, every organization block also requires
20 bytes of local data for its start information.
The CPU has a limited amount of memory for the temporary variables (local data) of blocks currently being
executed. The size of this memory area, the local data stack, is dependent on the CPU. The local data
stack is divided up equally among the priority classes (default). This means that every priority class has its
own local data area, thus guaranteeing that higher priority classes and their OBs also have space available
for their local data.
The following figure shows the assignment of local data to the priority classes in an example in which in the
L stack OB1 is interrupted by OB10 which is then interrupted by OB81.

Caution
When using temporary variables, remember that they are only valid within the
relevant block or are only available as previous local data for other blocks called in
this block. In particular, there is no guarantee that if you close and then re-open
the block, the temporary variables will have the same values they had when the
previous block call was completed. Temporary variables are by definition
undetermined when a block is called and must be re-initialized again when they
are used for the first time in the block.
All the temporary variables (TEMP) of an OB and its associated blocks are saved
in the L stack. If you use too many nesting levels when executing your blocks, the
L stack can overflow.
S7 CPUs change to STOP mode if the permitted L stack size for a program is
exceeded.
Test the L stack (the temporary variables) in your program.
The local data requirements of synchronous error OBs must be taken into
consideration.

Assigning Local Data to Priority Classes


Not every priority class requires the same amount of memory in the local data stack. By assigning
parameters in STEP 7, you can set different sized local data areas for the individual priority classes for S7-

mk:@MSITStore:C:\Program%20Files%20(x86)\Siemens\Step7\S7bin\s7bashdB.chm::/bas00... 21.06.2020
Local Data Stack Seite 2 von 2

400 CPUs and for the CPU 318. Any priority classes you do not required can be deselected. With S7-400
CPUs and the CPU 318 the memory area for other priority classes is then increased. Deactivated OBs are
ignored during program execution and save cycle time.
With the other S7-300 CPUs every priority class is assigned a fixed amount of local data (256 bytes) that
cannot be changed.

mk:@MSITStore:C:\Program%20Files%20(x86)\Siemens\Step7\S7bin\s7bashdB.chm::/bas00... 21.06.2020

You might also like