• No results found

Evaluating Errors with Output Parameter RET_VAL

In document s7sfc_en-EN (Page 87-92)

Types of Error Information

A system function (SFC) executed in your user program indicates whether or not the CPU was able to execute the function of the SFC successfully.

You can obtain information about any errors that occurred in two ways: • In the BR bit of the status word

• In the output parameter RET_VAL (return value) Note

Before evaluating the output parameters specific to an SFC, you should always follow the steps below: • First, evaluate the BR bit of the status word.

• Then check the output parameter RET_VAL.

If the BR bit indicates that an error has occurred or if RET_VAL contains a general error code, you must not evaluate the SFC output parameter!

Error Information in the Return Value

A system function (SFC) indicates that an error occurred during its execution by entering the value "0" in the binary result bit (BR) of the status word. Some system functions provide an additional error code at an output known as the return value (RET_VAL) output. If a general error is entered in the output parameter RET_VAL (see below for explanation), this is only indicated by the value "0" in the BR bit of the status word.

The return value is of the data type integer (INT). The relationship of the return value to the value "0" indicates whether or not an error occurred during execution of the function.

CPU Execution of the SFC BR Return Value Sign of the Integer

With error(s) 0 less than "0" negative (sign bit is "1") Without error 1 greater than or

equal to "0"

positive (sign bit is "0")

2.1 Evaluating Errors with Output Parameter RET_VAL

System Software for S7-300/400 System and Standard Functions Volume 1/2

88 Reference Manual, 05/2010, A5E02789976-01

Reactions to Error Information

There are two different types of error code in RET_VAL as follows: • A general error code, that all system functions can output and

• A specific error code, that the system function can output and which relates to its specific function. You can write your program so that it reacts to the errors that occur during execution of a system function. This way you prevent further errors occurring as a result of the first error.

General and Specific Error Information

The return value (RET_VAL) of a system function provides one of the two following types of error codes:

• A general error code, that relates to errors that can occur in any system function. • A specific error code, that relates only to the particular system function.

Although the data type of the output parameter RET_VAL is integer (INT), the error codes for system functions are grouped according to hexadecimal values. If you want to examine a return value and compare the value with the error codes listed in this manual, then display the error code in

hexadecimal format.

The figure below shows the structure of a system function error code in hexadecimal format.

Error code, for example W#16#8081

Sign bit = 1 indicates that an error has occurred.

15 8 7 0

1

X

Event number or error class and single error

x = ‘0’ indicates that this is a specific error code from an SFC. The error

codes are listed in the section entitled "Error Information" in the descriptions of the individual system functions.

x > ‘0’ indicates that this is a general error code from an SFC. In this

case, x is the number of the SFC parameter that caused the error. The possible error codes are shown in the following table.

2.1 Evaluating Errors with Output Parameter RET_VAL

General Error Information

The general error code indicates errors that can occur in any system function. A general error code consists of the following two numbers:

• A parameter number from 1 to 111, where 1 indicates the first parameter, 2 indicates the second parameter of the SFC, etc.

• An event number from 0 to 127. The event number indicates that a synchronous error occurred. The following table lists the codes for general errors and an explanation of each error.

0 7 8 15 Bits Sign Event number Parameter number 1 Note

If a general error code was entered in RET_VAL, the following situations are possible: • The action associated with the SFC may have been started or already completed.

• A specific SFC error may have occurred when the action was performed. As a result of a general error that occurred later, the specific error could, however, no longer be indicated.

Specific Error Information

Some system functions (SFCs) have a return value that provides a specific error code. This error code indicates that an error pertaining to a particular system function occurred during the execution of the function (see figure). A specific error code consists of the following two numbers:

• An error class from 0 to 7. • An error number from 0 to 15.

0 7 8 15 Bits Sign Error no. Error class 1 3 4 0 1

2.1 Evaluating Errors with Output Parameter RET_VAL

System Software for S7-300/400 System and Standard Functions Volume 1/2

90 Reference Manual, 05/2010, A5E02789976-01

General Error Codes

The following table explains the general error codes of a return value. The error code is shown in hexadecimal format. The letter x in each code number is simply a place holder and represents the number of the system function parameter that caused the error.

Error Code (W#16#...) Explanation

8x7F Internal error

This error code indicates an internal error at parameter x. 8x01 Illegal syntax ID at an ANYparameter

8x22 8x23

Range length error when reading a parameter. Range length error when writing a parameter.

This error code indicates that the parameter x is located either entirely or partly outside the range of an address or that the length of a bit range is not a multiple of 8 with an ANY parameter.

8x24 8x25

Range error when reading a parameter. Range error when writing a parameter.

This error code indicates that the parameter x is located in a range that is illegal for the system function. Refer to the descriptions of the individual functions for information about the illegal ranges.

8x24 8x25

Range error when reading a parameter. Range error when writing a parameter.

This error code indicates that the parameter x is located in a range that is illegal for the system function. Refer to the descriptions of the individual functions for information about the illegal ranges.

8x26 The parameter contains a timer number that is too high.

This error code indicates that the timer specified in parameter x does not exist. 8x27 The parameter contains a counter number that is too high (counter number error).

This error code indicates that the counter specified in parameter x does not exist. 8x28

8x29

Alignment error when reading a parameter. Alignment error when writing a parameter.

This error code indicates that the reference to parameter x is a bit address that is not equal to 0.

8x30 8x31

The parameter is located in a read-only global DB. The parameter is located in a read-only instance DB.

This error code indicates that parameter x is located in a read-only data block. If the data block was opened by the system function itself, the system function always returns the value W#16#8x30.

8x32 8x34 8x35

The parameter contains a DB number that is too high (DB number error). The parameter contains an FC number that is too high (FC number error). The parameter contains an FB number that is too high (FB number error).

This error code indicates that parameter x contains a block number higher than the highest permitted number.

8x3A 8x3C 8x3E

The parameter contains the number of a DB that is not loaded. The parameter contains the number of an FC that is not loaded. The parameter contains the number of an FB that is not loaded.

2.1 Evaluating Errors with Output Parameter RET_VAL

Error Code (W#16#...) Explanation

8x42 8x43

An access error occurred while the system was attempting to read a parameter from the peripheral input area.

An access error occurred while the system was attempting to write a parameter to the peripheral output area.

8x44 8x45

Error in the nth (n > 1) read access after an error occurred. Error in the nth (n > 1) write access after an error occurred.

In document s7sfc_en-EN (Page 87-92)