Result Modes

The MELSEC Communication plug-in offers two different types of result modes: "Free-running" and "Dequeue from buffer". You have to set the desired mode in the plug-in configuration under the category Result Handling Behavior.

Regardless of the selected result mode, the field "gMV_LastResultId" always indicates whether a new result is available. It contains the ID of the latest result and is updated whenever a new result becomes available. Hence, the ID will always increase monotonically unless the vision system is restarted intermittently. Initially, it is set to 0, which means that no result is available yet. The ID of the first result record will be 1 because result IDs are strictly positive.

Depending on the selected mode, the results will be provided in different ways as described below.

Available Result Modes

"Free-running" Mode

If this mode is selected, a new result is written to the respective result field as soon as it becomes available. This is convenient for certain monitoring applications in conjunction with a continuous execution, especially if the execution cycle is synchronized independently, for example, through a hardware trigger, or if the timing of the application is sufficiently non-critical.

Generally, the consistency of a given result record may not be guaranteed in free-running mode. This is because a new result immediately overwrites the current one, regardless of whether the PLC has finished processing this record. Consequently, it is possible that some results may get lost.

"Dequeue from buffer" Mode

If this mode is selected, an internal FIFO queue of the MELSEC Communication plug-in is used to save incoming results. The buffer is internal to the MELSEC Communication plug-in. Its capacity is defined by the parameter "Result buffer capacity" in the plug-in configuration. It must not be confused with "ResultBufferSize" in the MERLIC INI file which refers to the result buffer inside MERLIC.

Once a new result is available, it is first enqueued in the respective buffer. The PLC can then request that the oldest result record is written to the corresponding fields using the "DequeueResult" command. The requested result record is then immediately removed from the queue. If the PLC does not dequeue the results fast enough and the result buffer capacity is exceeded, the oldest result in the buffer is dropped. This means the next result to be dequeued is lost when the buffer overflows. In this case, the field "gMV_DroppedResultCount" will be incremented for each dropped result, starting from its initial value of 0. Thus, it contains the number of results that have been dropped when using the "Dequeue from buffer" result mode.

The regular command handshake provides the synchronization that is necessary to ensure the consistency of the result record. For more information, see Communication between Plug-in and PLC.

Result Record

The result record is returned after an execution and includes the fields below in the PLC memory. They represent the currently displayed result and are collectively updated once a new result becomes available (in "Free-running" mode) or when a result is dequeued from the buffer (in "Dequeue from buffer" mode).

Field

Description

gMV_ResultId

ID of the currently displayed result.

gMV_ResultRecipeId

ID of the recipe which produced the displayed result.

gMV_ResultJobId

ID of the job which produced the displayed result.

gMV_ResultState

State of the displayed result:

  • 1 = completed
  • 2 = processing
  • 3 = aborted
  • 4 = failed

gMV_ResultUseArray_<TYPE>...

Indicator whether any results of the respective data type are available to be queried. It contains an array in which each bit is assigned as indicator to a specific result of this data type. The size of the array depends on the configuration of the plug-in, that is, it depends on the setting for the respective result data type in the category Writing Data to PLC Memory.

For example, if the plug-in parameter "INT (signed 16-bit integer) result allocation" is set to 2, the field "gMV_ResultUseArray_INT" will be added to the PLC memory. If the first two bits of "gMV_ResultUseArray_INT" are TRUE, both results of data type INT are available.

gMV_Result_<TYPE>_<INDEX>

Actual result values of the respective data types. Each result is written to its own field. The label of a result field is composed of the prefix "gMV_Result_" followed by the data type and the index of the result. For example, the field "gMV_Result_INT_0" contains the value of the first result of data type INT.

These type of fields will only be added to the PLC memory if the configuration of the plug-in is set accordingly. For example, if the plug-in parameter "INT (signed 16-bit integer) result allocation" is set to 2, two fields for the result values will be added to the PLC memory: "gMV_Result_INT_0" and "gMV_Result_INT_1". After an execution, the first two bits of "gMV_ResultUseArray_INT" will indicate whether these INT results are available.