terça-feira, 24 de junho de 2025

Programming a PLC Siemens - Multi-Instances

 Multi-instances 

Definition 


When a function block (FB) calls another FB, its instance data can also be stored in the instance DB of the calling FB. This type of block call is referred to as a multi-instance.


Advantages


The use of multi-instances provides the following advantages: 


Good structuring options for complex blocks 


Lower number of instance DBs 


Easy programming of local subprograms, for example for local timers or edge evaluations.


How multi-instances work


The following figure shows an FB that uses another FB ("Valve"). "Valve" is called as a multi-instance, i.e. it stores its data in the instance DB of the calling FB. Multi-instance data is located in the "Static" section of the calling block. In CPUs of the S7-1200/S7-1500 series, the instance can also be located in the instance DB of another function block.


Creating multi-instances


You have the following options for creating a multi-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.


You declare the multi-instance directly in the interface of the calling block.


You declare the multi-instance in the interface of another function block (S7-1200/S7-1500).


See also: Declaring multi-instances


ARRAYs of multi-instances


Multi-instances can also be created as an ARRAY. You can address the individual ARRAY elements using a variable index, for example when processing program loops. 





 



You declare ARRAYs of multi-instances directly in the interface of a function block.


Calling multi-instances 


When a multi-instance is called, the assigned instance is indicated. The following figures show the call of the "Block" block as a multi-instance in LAD. 


In the following example, the instance is located locally in the instance DB of the calling block:


 



In the following example, the instance is located in the instance DB "MyOtherFB" (S7-1200/S7-1500):


 



In the following example, the instance is located in an ARRAY of multi-instances in instance DB "MyOtherFB" (S7-1200/S7-1500):


 




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 


Instance data blocks 

Basics of instances 

Single instances 

Example of using parameter instances in an ARRAY of multi-instances 

EMERSON EDUARDO RODRIGUES


Nenhum comentário:

Postar um comentário