show the entry list
STEP 7 -- Creating S7 programs -- Calling blocks and functions
What are the block protection facilities available in STEP 7 to protect the the know-how of your blocks?
What is the maximum number of parameters that can be assigned to an FC and FB in the S7-300 CPU?
How can you install block protection for self-created blocks?
Tips and tricks for calling and parameterizing SFBs, SFCs and IEC standard functions
How do you transfer string variables from a data block to a function blocks, for example?
Information about "Calling blocks and functions"
How do you parameterize a structured data type in the IN_OUT area of an FB and a function call with an ARRAY variable?
How do you create and update multiple instances?
How do you update invalid block calls (time stamp conflicts) in calling blocks?
How do you perform a block-consistency check following changes in the STEP 7 program?
How do you determine the block number of the "Data Types for Parameters" in the program and how can you pass this parameter on to an FC?
What is the difference between the CALL statement and the UC or CC call statement?
What is the difference between an instance data block and a global data block and how does a CALL call influence the DB register?
How do you determine the block number of the "Data Types for Parameters" in the program and how can you pass this parameter on to an FC?
Part number:

Instructions
Using the following program codes, you can determine the number of the "Data Types for Parameters" (BLOCK_FC, BLOCK_FB, TIMER or COUNTER).

Example 1 for function blocks
In FB1, the "Time_1" variable of the "Timer" type is declared in the variable declaration and when FB1 is called in FB2, the "Time_1" variable is parameterized with the "T5" timer. The number 5 is determined for "T5" in the program code shown in Fig. 01.


Fig. 01

Example 2 for functions
In FC1, the "Time_1" variable of the "Timer" type is declared in the variable declaration and when FC1 is called in FC2, the "Time_1" variable is parameterized with the "T8" timer. The number 8 is determined for "T8" in the program code shown in Fig. 02.


Fig. 02

In the case of function blocks with multi-instances, you have to make an addition to the program in Fig. 01:

TAR2                        //Address offset of the multi-instance
LAR1 P##Time_1
+AR1                        //Add address offset of the multi-instance to the current address
L W[AR1,P#0.0]
T MW00

When a function (FC) is called, it is not permissible to transfer directly a parameter of the "BLOCK_DB" type, for example. If you attempt to use a parameter type as current parameter when a function is called, you get the following error message:

"Illegal parameter assignment for <parameter name>"

It permissible to pass on a BLOCK_DB parameter type only when an FB is called (from an FB or an FC).

Direct passing on of parameter types is not permissible when a function is called (from an FB or an FC). More detailed information on this is available in the Online Help of STEP 7 under the topic of "Legal data types in the transfer of parameters".

However, if you still wish to pass on information from the BLOCK_DB parameter to an FC, the DB number can be determined and be transferred in an FC call by means of an elementary data type (e.g. WORD).

In the following example, the FB100 function block has an IN parameter of the "BLOCK_DB" (InData) type. In order to pass on this parameter during an FC101 call, the number of the data block transmitted with "BLOCK_DB" is determined and is saved in a temporary WORD variable (DB_No.). When the function is called, the data block number is transmitted as a WORD parameter instead of the BLOCK_DB parameter.


Fig. 03

If the interface of the caller FB can be made with a WORD parameter for transferring the DB number, this parameter can be passed on directly to the FC that is being called.


Fig. 04

 Entry ID:18287140   Date:2010-03-08 
I regard this article....as helpfulas not helpful                                 
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Help
Online Help
Guided Tour