||Tips and tricks for calling and parameterizing SFBs, SFCs and IEC standard functions|
||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.
||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.
||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.
||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.
||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.
||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.
Please also refer to the information in the Online Help of STEP 7, under "Format of the Data Type STRING".
||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.