Lec 06 Siemens Programming Blocks
Lec 06 Siemens Programming Blocks
Siemens Programming
Blocks
October 2024
❑ Function blocks are always executed when called from another logic block.
❑A function block can also be called several times at different points within a
program.
❑This facilitates the programming of frequently recurring complex functions.
❑The tags declared in the function block determine the structure of the
instance data block.
Siemens PLCs
Functions Blocks FBs
Note:
In FC programming, if you do not want to use the results of the FC
subroutines outside of it, it is always a good idea to use TEMP
variables, instead of Memory Bits (M) or Data Blocks (DB). This is
because of the possibility to call those M or DB addresses outside of
the FC, results in an inaccurate execution for the FC. Overall,
programmers do their best not to use Global variables in FC’s.
Siemens PLCs
Global data blocks DBs
❑ In contrast to logic blocks, data blocks contain no instructions. Rather, they serve
as memory for user data.
❑ Data blocks thus contain variable data that is used by the user program.
❑ You can define the structure of global data blocks as required. Global data blocks
store data that can be used by all other blocks.
❑ Only the associated function block should access instance data blocks.
❑ The maximum size of data blocks varies depending on the CPU.
❑ Application examples for global data blocks are:
❖ Saving of information about a storage system. "Which product is located
where?“
❖ Saving of recipes for particular products.
Siemens PLCs
Global data blocks DBs
Siemens PLCs
Instances and multi-instances in SIMATIC S7-1200
❑ An instance is assigned to every call of a function block and serves as a data
memory.
❑ It stores the actual parameters and the static data of the function block.
❖ Call as a single instance:
➢ A separate instance data block for each instance of a function block
❖ Call as a multi-instance:
➢ One instance data block for several instances of one or more function
blocks
Siemens PLCs
Instance data blocks / Single instances
The figure shows the control of
two motors using one function
block FB10 and two different
data blocks:
The different data for the
individual motors, such as
speed, acceleration time and
total operating time, are saved
in the instance data blocks
DB10 and DB11.
Siemens PLCs
Multi-instances