Logical blocks include: function (FC), function block (FB), organization block (OB), which are made up of variable declaration tables, code snippets, and their properties.
1. local Variable Declaration table
Each logical block is preceded by a variable declaration table, which is called a local variable declaration table.
Local data includes parameters, local variables.
Local variables include static variables, temporary variables.
1) function (FC) variable Introduction
FC has no background data block, that is, FC cannot use static variables, and temporary variables can be used. The input, output, and I/O parameters are stored as pointers to arguments in the extra space reserved by the operating system for parameter passing.
2) function block (FB) variable Introduction
FB In addition to temporary variables, all parameters of the storage space in the background data block.
3) Tissue block (OB)
OB has only temporary variables, other variables are managed by the operating system, and users cannot participate.
2. Data types for local variables
A local variable can be defined as a basic data type, a duplex data type, or a parameter type that is specifically used for parameter passing, such as a timer, a counter, an address or a pointer to a block, and so on.
3. How to use variables
1) Use the variable name, preceded by the prefix "#", to distinguish it from the symbolic address in the symbol table. In incremental mode, the prefix is automatically generated.
2) directly use the address of the local variable, which is only valid for the background data block and the L stack.
In addition, when calling the FB block, the background data block needs to be generated before the call, and its sequential format needs to be consistent with the variable declaration table.
Siemens PLC Learning Note 16-(Structure of logical blocks)