You are on page 1of 17

http://support.automation.siemens.

com/US/view/99/22109936

S7-SCL -- Analyzing error messages -- Diagnosing errors Entry ID:22109936 Date:2007-10-08 S7-SCL -- Analyzing error messages -- Diagnosing errors What do you use the "Set OK Flag" option for? Why can't you load an OB (e.g. OB35) into the CPU? Why is the following error message displayed when a REAL value is assigned: "Invalid data type"? SCL compiler message: "Incorrect block" Why are IF statements with the comparison of two variables of the type WORD / DWORD not compiled? Tips and tricks about error messages and warnings in S7-SCL Information about the topic of "Diagnosing errors" Why do you get an error message when compiling with German mnemonics when the variables "a" and "e" are declared with the ARRAY data type? What do you use the "Set OK Flag" option for? Instructions: The "Set OK Flag" option is for noting the correct or incorrect execution of a statement in the block. It is a local flag of the BOOL type with the predefined name "OK". It is therefore not necessary to negotiate the OK flag. No. Procedure 1 To be able to use the OK flag in your user program, you must select the "Set OK flag" compiler option before compiling. For this, you open the "Customize" dialog in S7-SCL via "Tools > Customize... > Tab: Compiler". Activate the "Set OK flag" option as shown in Fig. 01 and close the dialog with OK.

Page 1 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Fig. 01 3 Now, in the S7-SCL program you can call the statement and execute the operation. ... OK:= 1; //the OK flag is set to TRUE. <statement>; //execution of the operation. X:= OK; //TRUE: Operation correct, FALSE: Operation incorrect... 4 Save and compile your S7-SCL program and load the program into your CPU.

If an error occurs during an operation (e.g. overflow in a multiplication), the OK flag (X of data type: BOOL) is set to FALSE. When you quit the block, the last value of the OK flag is stored in the output parameter ENO and can thus be evaluated by the calling block. Example with the standard function ABS The number range of the INT data type is from +32767 to -32768 and thus the absolute value of 32768 cannot be +32768. The OK Flag is then set to FALSE, because the operation is incorrect as in Fig. 02.

Page 2 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Fig. 02 If you now use the data type DINT to remedy as in Fig. 03, the operation is correct and the value +32768 is displayed correctly. The OK flag is set to TRUE.

Fig. 03

Page 3 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

More information is available in the Online Help of S7-SCL under "Flags (OK flag)". Keywords: Overrun Why can't you load an OB (e.g. OB35) into the CPU? Description: If you get the following error message: "Block OB35 could not be copied" Details: "(D21A) length of the local data or write protect recognition is incorrect", then the local data of your organization block is not long enough. The above-mentioned message can appear if your block is configured as follows: ORGANIZATION_BLOCK OB35 mw10:= 1; END_ORGANIZATION_BLOCK Even if a new project is created with the same block, this OB cannot be loaded into the CPU. An OB must always have a local data length of at least 20 bytes. The start information of the OB is stored there. The statements of the above-mentioned block can be compiled without error, but cannot be loaded into the CPU. Remedy: To maintain the minimum local data length of 20 bytes, create the following in the SCL source via "Insert / Block Template > OB": ORGANIZATION_BLOCK OBxxx VAR_TEMP // reserved info : ARRAY[0..19] OF BYTE; // temporary variables END_VAR // statements ; END_ORGANIZATION_BLOCK The template consists of: The block header ORGANIZATION_BLOCK with a wildcard for the block designation The declaration block for temporary variables (the 20 bytes required for the operating system are declared implicitly) The code word BEGIN for the statement part The statement for the block end END_ORGANIZATION_BLOCK Keywords: Local data length, Load CPU

Page 4 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Why is the following error message displayed when a REAL value is assigned: "Invalid data type"? Description: If the absolute statement DB1.DBD0 := 50.0; is to be compiled in S7-SCL, you receive the error message "The code generator was not called due to an error" and "Invalid data type". The blocks cannot be compiled. If you change the programming from absolute to symbolic, that is Values.Value1 := 50.0; no error message appears when compiling. Values stands for the symbolic name of DB1 and Value1 designates a variable of the REAL type with the address 0.0 in DB1 (data block 1). Remedy: Please note that with absolute programming, the corresponding type conversion has to be used. When variables are linked, they have to be of the same data type. This applies also to value assignment and the function and data block parameters. In the above case, the variable is not of the required data type. Here, you have to use the corresponding conversion function. In S7-SCL, there are two kinds of conversion functions: The Implicit Conversion Functions (Class A) are automatically executed by S7-SCL, e.g. BOOL_TO_BYTE, BOOL_TO_WORD. The Explicit Conversion Functions (Class B) have to be declared in the program, e.g. WORD_TO_BYTE, WORD_TO_BOOL. More information about conversion functions can be found in the SCL Online Help, under: Conversion of data types Class A conversion functions Class B conversion functions The above absolute value assignment therefore has to be programmed as follows: DB1.DBD0 := REAL_TO_DWORD(50.0); In symbolic programming, the corresponding data type is defined so that a conversion is not necessary. Keywords: Type conflict SCL compiler message: "Incorrect block" QUESTION:

Page 5 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Why when compiling my SCL source, do I get the error message: "Incorrect block"? ANSWER: One reason for this error message could be that you are using the GOTO statement in your SCL source and have NOT inserted a semicolon in the statement part of your SCL source for the jump labels (in the attached example this would concern "Label3"). Remedy: After a jump label has been set, the compiler expects a statement part that can be executed. By setting a " ; " (semicolon) after the label (here: "Label3:;") the compiler is able to recognize that no statements are assigned to the label condition.

scl_goto.pdf ( 1 KB ) Keywords: SCL compiler, Compiler error, Compiler

Why are IF statements with the comparison of two variables of the type WORD / DWORD not compiled? Instructions: When comparing operands within an IF instruction, S7-SCL only permits comparison operations with "=" and "<>", not comparison operations with ">" and "<" if variables of the type WORD and DWORD are declared. As a remedy, we recommend declaring the variables of the DINT type as follows. Comparison of operands in an IF statement Variable type: WORD Only with "=" and "<>" Table 1 Comparison of operands with "=" in the IF statement when operands are of the type "DWORD". Variable type: DINT All: "=", "<>", ">" and "<"

Fig. 01 Comparison of operands with "<" in the IF statement, here the operands of the type "DINT" must be declared.

Page 6 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Fig. 02 If it is not possible to declare the variables "Var_max" and "Var_min" of the type DINT, you must first do a type conversion. Information on this is available in our FAQ "How can you compare variables of the type WORD or DWORD with each other?" in Entry ID: !21214698. Keywords: Greater than or equal to, Less than or equal to, Does not equal, Message: "Invalid operand types" Fig. 01

Fig. 02

Tips and tricks about error messages and warnings in S7-SCL Description: This entry contains some tips and tricks about error messages and warnings. The following cases are explained:

Page 7 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

1. 2. 3. 4. 5. 6. 7. 8. 9.

"Invalid data type" message when a DWORD-type variable is assigned a real value Error message in the output window does not match the line number Message: "The FB is not available or the instance declaration is missing" Message: "Character strings have different lengths" CPU message: "STOP due to unknown OP code" "Syntax error with UNLINKED" when compiling UDTs "Syntax error with 2#1100_1100" when compiling a DB Maximum length of the negotiation part reached (64 Kbytes) Message: "16#8184" at program runtime in the CPU

The table below provides the causes and remedies for the above: No. Causes and remedies 1 "Invalid data type" message when a DWORD-type variable is assigned a real value Note that only the data types BOOL, BYTE, WORD and DWORD are permitted for absolute DB accesses. Fig. 01 shows examples of when a data type has to be converted.

Fig. 01 2 Error message in the output window does not match the line number For the lines with numbers greater than 65535, the S7-SCL compiler starts counting again from the number 1. For example, for a programming error in line 65537 of the S7-SCL source, the following line number is output: "F: Z 00001 error xyz" instead of "F: Z 65537 error xyz" Remedy:

Page 8 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Double-click on the error message in the output window of the S7-SCL compiler, the cursor then jumps to the incorrect line. If the programming error is not in the line specified, you can jump to the line with the incorrect statement using the menu command "Edit > Go To > Line..." and entering "65536 + displayed error number". Note: We recommend reducing the number of lines in the S7-SCL source. Then recompile the source. 3 Message: "The FB is not available or the instance declaration is missing" This message is issued if an FC/FB/SFB/SFC block is called in the program, which is not in the block folder and which cannot be copied from the libraries. Remedy: Copy the blocks concerned manually into the block folder and recompile S7-SCL. 4 Message: "Character strings have different lengths" The example as shown in Fig. 02 contains the two functions FC1 and FC2 with the two string variables "name_1" and "name_2". When FC1 is compiled, you get the warning "Character strings have different lengths". On the right side of the assignment ("name_1") there is probably a STRING during runtime that is longer than the type of STRING variable permissible on the left side ("name_2"). Remedy: We recommend declaring a STRING length of 254 characters for the variable "name_2" on the left side. If you compile function FC2 with this declaration, the warning no longer appears.

Fig. 02 Note: If you increase the STRING length to 254, there is a greater load on the local storage space. 5 CPU message: "STOP due to unknown OP code" This CPU message is issued if you are using the conversion function "WORD_TO_BLOCK_DB (...)" in S7-SCL and you program the following statement Display := WORD_TO_INT(BYTE_TO_WORD (WORD_TO_BLOCK_DB (DBNo).DB

Page 9 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

[DBIndex])); Remedy: We recommend replacing the statement given above with the following two statements: tmp := WORD_TO_BLOCK_DB (DBNo).DB[DBIndex]; Display := WORD_TO_INT (BYTE_TO_WORD (tmp)); The message above then no longer appears and your CPU does not go into the STOP mode. 6 "Syntax error with UNLINKED" when compiling UDTs A UDT cannot be compiled in S7-SCL if it is identified before the declaration with "UNLINKED". The "UNLINKED" attribute must not be used in a UDT. Compilation is terminated with the error message "Syntax error with UNLINKED". This also applies for the declaration in an STL source. UDTs are not usually loaded into the S7 CPU, but are always stored "offline" in the S7 user program. Background In the case of data blocks, the "UNLINKED" attribute means that the DB concerned is not incorporated in the program is stored only in the load memory doesn't take up any space. The "UNLINKED" attribute is declared in the data block's header (Fig. 03).

Fig. 03 7 "Syntax error with 2#1100_1100" when compiling a DB In a data block of a variable of the BYTE type, if you assign a binary number as initial value, the error message "Syntax error with 2#..." when you compile the S7-SCL source. Example: Var1: BYTE:= b#2#1100_1100; In S7-SCL, data blocks are generated with the STL compiler. If you initialize variables in data blocks both in the DB negotiation part and in the DB assignment part, you must use STL notation exclusively. In the example of variables of the Byte type you can therefore specify an initial value only as hexadecimal number. The S7-SCL notation (e.g. B#2#1100_1100) can only be used in code blocks, because the S7-SCL compiler is used here.

Page 10 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Remedy: Change the binary number of the initial value to a hexadecimal number, e.g.: Var1: BYTE:= b#16#cc; Note: The S7-SCL notation is available in the S7-SCL Online Help under "Notation of constants" and the STL notation is available in the STEP 7 Online Help under "Help on STL > Entering and displaying constants". 8 Maximum length of the negotiation part reached (64 Kbytes) This message appears if the size of the interface to the automation device (64 Kbytes) is exceeded. Each separate elementary declaration needs 2 bytes. The declarations in multiinstances or user-defined data types (UDTs) must be taken into account like structures (STRUCT) in which each separate component needs 2 bytes. Remedy: The behavior described above can be cleared as follows: 1. Reduce the length of the variable name to an effective minimum. 2. Delete the declarations not required. 3. Use the ARRAY declarations by declaring an ARRAY of BOOL, for example, instead of naming each bit individually. 4. If points 1 to 3 do not help, split your S7-SCL source into two or more S7-SCL sources. 9 Message: "16#8184" at program runtime in the CPU When a block written in STL with transfer parameters of the ANY type is called, no parameters of the STRING data type may be transferred. This is a system property. Remedy: If you have to transfer parameters of the STRING type, then call those blocks only in STL. If you can use other data types, transfer only parameters of the data types ARRAY or STRUCT instead of parameters of the STRING data type. Keywords: Compiler message, Compiler error, Compilation error Information about the topic of "Diagnosing errors" Instructions: There is information about the topic of "Diagnosing errors" available in the following manuals and sections. Document Manual "S7-SCL V5.3 for S7300/400" Edition Chapter / Section 01/2005 4.7.5 Debugging the Program After Compilation Entry ID 5581793

Why do you get an error message when compiling with German mnemonics when the variables "a" and "e" are declared with the ARRAY data type? Description: If you create an S7-SCL program with English mnemonics and the array declaration is defined in the

Page 11 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

program with the variable name "a" or "e", then this declaration can be compiled without any problems. After switchover from English mnemonics to German mnemonics the error message "ARRAY designator is a reserved designator" appears during compilation.

Fig. 01 If, in the opposite case, you create an S7-SCL program with German mnemonics and an array declaration is defined in the program with the variable name "I" or "Q", then this declaration can be compiled without any problems. After switchover from German mnemonics to English mnemonics the error message "ARRAY designator is a reserved designator" appears during compilation.

Fig. 02 Cause: The characters "a", "e" and "m" are predefined in the German mnemonics as bit fields for "inputs", "outputs" and "markers" respectively. In the international mnemonics the corresponding characters are "I", "Q" and "m". The same holds for the designators "ex", "eb", "ew" and "ed". The language set has not affect. Remedy: Change the variables in the declaration as in Fig. 03 and avoid using the designators described above that are predefined as bit fields.

Page 12 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Fig. 03 If it is too much trouble to make these program changes for your STEP 7 project, we recommend working with the mnemonics (German or English) used to create the S7-SCL sources. You set the mnemonics in the SIMATIC Manager via "Options > Settings... > Tab: Language".

Fig. 04 Note: More information is also available in the S7-SCL Online Help under "Address Identifiers and Block Keywords". Fig. 01

Page 13 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Fig. 02

Page 14 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Fig. 03

Fig. 04

Page 15 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Entry ID:22109936 Date:2009-07-14


Siemens AG 2010 - Corporate Information - Privacy Policy - Terms of Use

Page 16 of 17

3/30/2010 3:10:29 AM

http://support.automation.siemens.com/US/view/99/22109936

Page 17 of 17

3/30/2010 3:10:29 AM

You might also like