terça-feira, 24 de junho de 2025

Programming a PLC SIEMENS - Single Instances

Single instances 

Definition 


An instance of a function block (FB) that is located in its own instance DB is referred to as a single instance. The instance DB thus contains the working data for an individual block call.


Advantages


The use of single instances provides the following advantages: 


Reusability of the function blocks 


Good structuring options for simple programs


How single instances work


The following figure shows the FB "Caller" that uses another FB ("Valve"). "Valve" is called as a single instance, i.e. it stores its data in its own instance DB. 





The structure of the instance data block is defined by the interface of the corresponding FB and can only be changed there. The instance DB contains the following data: 


Block parameters 


The block parameters in the "Input", "Output" and "InOut" sections form the interface of the block for the call in the program. 


Static local data


Static local data in the "Static" section is used for permanently storing intermediate results beyond the current program cycle, for example for storing the signal state for an edge evaluation.


Creating single instances


You have the following options for creating a single instance:


When you call an FB in the program, the "Call options" dialog appears. Here, you can specify whether you want to call the FB as a single instance, multi-instance or parameter instance.


When you create a new data block, the "Add new block" dialog opens. Here, you can select a function block that you want to create an instance data block for under "Type". 


Calling single instances


When a single instance is called, the assigned instance data block is indicated.


The following figure shows the call of the "Block" block as a single instance in LAD. The instance data block "BlockData" is above the call.


Note 


Calling and addressing blocks in namespaces


Blocks located in namespaces are represented in the program code in IEC-compliant notation:


The block name is not in quotation marks.


The namespace precedes the block name, separated by a dot.


You can find detailed information on the notation of namespaces under: Introduction to namespaces

 




--------------------------------------------------------------------------------


See also 


Basics of instances 

Multi-instances 


Nenhum comentário:

Postar um comentário