No Copy


No Right Click

Saturday, December 3, 2011

How can the program runtime be optimized if the main memory of the CPU is too small for the runtime-relevant STEP 7 program?"

Instructions
The sections of the S7 user program relevant to the runtime are in the main memory of the CPU. These are essentially the program code and the user data. The CPU's load memory contains the complete user program including the module configuration and module parameters. The next table contains information on the topics listed below:
  • Configuring data blocks with the "Unlinked" attribute
  • Influence of the operand area on the memory requirements
  • Different load memory usage for two data blocks of the same size
  • Variable declaration in data blocks
No. Information about optimizing program sequences
1 Configuring data blocks with the "Unlinked" attribute
Since the main memory has only a limited size, for recipe management, for example, multiple data blocks can be different recipe values can only be stored in the load memory. Then, in the main memory is only a working DB that contains the current recipe.
Fig. 01
If DBs are configured with the "Unlinked" property and loaded into the CPU, then those data blocks are only available in the CPU's load memory and hence do not take up any space in the main memory. Using this method it is possible to save space in the CPU's main memory. The contents of these data blocks can only be transferred into the main memory with system functions SFC20 "BLKMOV" or SFC83 "READ_DBL". However, if you try to load the data of of these data blocks into Accu 1 with a load command, the CPU goes into STOP.

Fig. 02
Open "Object Properties" of the data block and activate the "Unlinked" attribute in the "General - Part 2" tab (Fig. 2). After the data block has been loaded into the CPU, the data block is only stored in the load memory.

Fig. 03
Using system function SFC20 you can copy the data from the load memory into the main memory (as in Fig. 03) and subsequently load it into Accu 1 using "L DB20.DBW 0", for example.
NoteIn the STL sources, this property is allocated to a data block with the key word Unlinked (between "DATA_BLOCK DB “ and the STRUCT definition of the data block).
2 Influence of the operand area on the memory requirements
The operand area has a minor influence on the memory requirements when programming:
  • With inputs and outputs the limit lies between addresses 127.7 and 128.0.
  • The limit with markers, on the other hand, lies between addresses 255.7 and 256.0.
To explain the behavior the two statements below are programmed in a function.
The statement:
U M256.0
= M0.0
requires 6 bytes in the main memory.
If you use the same statement with a smaller marker address, for example,
U M255.0
= M0.0
then only 4 bytes of main memory are required.
The empty function alone requires 38 bytes. Hence, in the main memory, the complete FC requires 38 bytes + number of bytes for the written statement.
3 Different load memory usage for two data blocks of the same size
A data block with 16 variables of the Boolean data type requires more load memory than a data block with a variable of the Word data type. One byte is required in a data block for each variable name and for each data type. This means:
  • DB with 16 variables of the Boolean data type:
    16 x 2 bytes (for name and data type) = 32 bytes
  • DB with 1 variable of the Word data type:
    1 x 2 bytes (for name and data type) = 2 bytes
4 Variable declaration in data blocks
The size of a data block is normally limited by the maximum available block size of the CPU used (for example, 64 KB with an S7-400 or 8 KB or 6 KB with an S7-300). There is yet another system limit in STEP 7 for the number of declarations in a data block. If you declare more than 32000 variables, an error message is displayed: "Declaration too long". The reason for this message is that 2 bytes per declaration are occupied in the internal 64-KB buffer (as described in point 3).
Remedy
Instead of programming the data block with numerous single variables, we recommend using arrays or multiple smaller data blocks. In addition, smaller data blocks can be opened and saved much more quickly in the editor.
Creation environment
The figures in this FAQ were created with STEP 7 V5.5.
Keywords
Integrated RAM, Memory Card, EPROM.

0 Comments:

#