Error Handling

When using the MODICON®* plug-in, basically two fields in the PLC memory are used to indicate the presence of errors: "GMV_ERRORCODE" and "GMV_ERRORCAUSE". By default, they are set to 0, indicating that no errors occurred.

When the plug-in starts, the "GMV_ERRORCODE" field is set to 1 indicating that no error is present. If an error occurs, both fields "GMV_ERRORCODE" and "GMV_ERRORCAUSE" are updated to reflect the error condition. The PLC needs to acknowledge the error by requesting the "AcknowledgeError" command, that is, by setting "GMV_REQCOMMANDCODE" to the respective command code. You can find the list of available command codes in the topic Communication between Plug-in and PLC .

In response, the plug-in will also set "GMV_ACKCOMMANDCODE" to the same command code. After the PLC has reset "GMV_REQCOMMANDCODE", "GMV_ERRORCODE" and "GMV_ERRORCAUSE", the plug-in will also reset "GMV_ACKCOMMANDCODE" to 0. With this handshaking mechanism, the PLC knows that the error fields have been updated.

If a new error occurs while a previous error is still displayed in "GMV_ERRORCODE" and "GMV_ERRORCAUSE", it will not overwrite these fields with the new error information. Instead, the previous error is first processed. As soon as "GMV_ACKCOMMANDCODE" has been reset to 0, the second error will be written to the error fields. If the value in "GMV_ERRORCODE" remains unchanged even after "GMV_ACKCOMMANDCODE" has been reset, it indicates that the same error occurred again. Then, the "AcknowledgeError" command has to be executed a second time to also acknowledge the second error. If no further errors have occurred in the meantime, the value of the "GMV_ERRORCODE" field will be reset to 1. This indicates that all errors have been acknowledged.

GMV_ERRORCODE

If an error occurs, this field contains a numeric unsigned 16-bit integer that represents the error code. The error code provides information about the severity, the affected component, and the nature of the error according to the error definitions provided by the Communicator API.

The severity of the error is represented by the most significant 4 bits in the error code. We differentiate between the following severities:

Value

Severity

1

Critical

2

Error

4

Warning

The affected component where the error occurred is represented by the next four bits with lower significance. The following table shows the possible components:

Value

Affected component

1

Vision system (MERLIC)

2

MVApp / recipe

4

Communicator

8

MODICON®* plug-in

The least significant 8 bits indicate the nature of the error according to the MV_CODE_* definitions provided by the Communicator API. You can find the definitions in the documentation of the API header mv_error_def.h in the Communicator reference documentation.

For example, if the "GMV_ERRORCODE" field contains the hexadecimal error code 0x2139, the respective bits indicate that an error (0x2000) occurred in the vision system (0x0100) because of an image acquisition error (0x39).

GMV_ERRORCAUSE

This field indicates which command caused the error. Thus, it assumes the same numeric value as given in the "GMV_REQCOMMANDCODE" and "GMV_ACKCOMMANDCODE" fields. You can find an overview of the available commands and their codes in the topic Communication between Plug-in and PLC.

Sometimes, errors can also occur spontaneously and are not caused by any command, for example, when the connection to a camera is lost. In such cases, "GMV_ERRORCAUSE" assumes the value 0 which represents "NoCommand". Only errors caused by commands which have been triggered by the same MODICON®* plug-in instance as well as spontaneous errors are processed. Hence, errors caused by a command issued by another plug-in instance are ignored.


* Modicon® is a registered trademark of Schneider Electric USA, Inc.