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?
Tips and tricks for calling and parameterizing SFBs, SFCs and IEC standard functions
Part number:

Instructions
This entry includes tips and tricks for calling and parameterizing SFBs, SFCs and IEC standard functions:

  1. General - where can you obtain information on the SFBs, SFCs and the IEC functions?
  2. How do you parameterize the inputs "IN1" and "IN2" of the IEC standard function FC11 (FIND)?
  3. What do you have to watch out for when configuring the ANY pointer of the ARRAY or STRUCT type at the "RECORD" output of SFC14/15?
  4. How can you transfer data areas of the "STRING" type with SFC20?
  5. Why is the return value RET_VAL of SFC20 different depending on the CPU used?
  6. Why does the function IEC FC 38 return the value "0" although the string variable is in the permissible range? 
  7. In which OBs are the SFBs for the communication jobs called up?

The table below provides information and remedies for the above.
 
No. Tips and tricks for calling and parameterizing SFBs, SFCs and IEC standard functions
1 General - where can you obtain information on the SFBs, SFCs and the IEC functions?
Information on the SFBs, SFCs and the IEC functions for configuring and parameterizing are available
  • In the Online Help by marking the block and pressing the F1 key
  • In the "System software for S7-300/400 system and standard functions" manual, Entry ID: 1214574.
2 How do you parameterize the inputs "IN1" and "IN2" of the IEC standard function FC11 (FIND)?
The character string "IN2" to be found must not be the same size as the character string "IN1". If the two character strings are identical, block FC11 (FIND) also reports zero. For queries about being equal use FC10 (EQ_STRNG) or combine both blocks. 
3 What do you have to watch out for when configuring the ANY pointer of the ARRAY or STRUCT type at the "RECORD" output of SFC14/15?
STEP 7 always stores ARRAYs and STRUCTs in word boundaries in the memory. An odd byte number (e.g. ARRAY <1..5>) is filled with 1 byte, so that an incorrect length is transferred via the ANY pointer. This leads to the following error message:
  • 80B1: "The length of the specified target area is not equal to the length of the user data configured with STEP 7"

The length of the ANY pointer must always be specified precisely in bytes, e.g. with the syntax: "P#M280.0 BYTE 5". We recommend parameterizing the ANY variable of SFC14 /15 via the absolute programming.

4 How can you transfer data areas of the "STRING" type with SFC20?
Using the system function SFC20 (BLKMOV) you can transfer data areas from a data block DB1 to a data block DB2, for example. When writing a local variable of the STRING type in a data block, you must preset that variable beforehand. You must then program that variable symbolically (not absolutely) for transfer to SFC20. Fig. 01 shows how the SFC20 can be programmed with a STRING variable.


Fig. 01

5 Why is the return value RET_VAL of SFC20 different depending on the CPU used?
When assigning an inadmissible ANY pointer with the length "0", there is a difference between the return values of an S7-300 and an S7-400 CPU. There are different return values of SFC20 due to the different ways the CPUs handle errors.
6 Why does the function IEC FC 38 return the value "0" although the string variable is in the permissible range? 
If the IEC function FC 38 is parameterized via a STRING variable that is defined in a DB without an initial value, then a "0" is given in the byte for the actual length. The variable has not been initialized in the DB. This means that the variable is installed with the information "defined length", but without any information about the actual length. Now, if a character string is entered via the variable table, without adapting the byte for the actual length, the character string is not recognized by the CPU. The character string is only recognized by the CPU once the byte for the actual length has been adapted.


Fig. 02

Note
Please also refer to the information in the Online Help of STEP 7, under "Format of the Data Type STRING".

7 In which OBs are the SFBs for the communication jobs called up?
All SFBs that you require for data exchange or for program management (setting AS to STOP or to RUN) via the configured connections must be called in the startup OBs (OB100 in the S7-300, OB100 and OB101 in the S7-400) and in cyclic operation (OB1).

The OB100 is a startup OB and is run when the CPU is restarted (warm start). In this OB, the first communication trigger is enabled with markers M1.0 and M0.1, for example. A sample program, as well as further information about programming and parameterizing the SFB14 / SFB15 can be found in Entry ID: 1819293.

You must interconnect the parameters "REQ", "ID" and "PI_NAME" of the SFBs as follows in the startup OBs:

  • "REQ": Enables data exchange if certain conditions are met. Connect the "REQ" parameter to a boolean actual parameter with the status "0".
  • "ID": Reference to the local connection description which is allocated during the configuration of the connection. Connect the "ID" parameter in the format W#16#X where X is the "ID number" of the connection.
  • "PI_NAME": Indicates the memory area in which the name of the program which is being started (ASCII code) is saved. The parameter "PI_NAME" (SFB19 "START", SFB20 "STOP" or SFB21 "RESUME") must be connected to a string beginning "P_PROGRAM".

There is more information about the assignment of parameters to the SFBs available in the STEP 7 Online Help.

Keywords
STRING comparison

 Entry ID:12423713   Date:2011-07-20 
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