Fields for the Communication with the PLC
For each field in the .csv file, a specific memory block is reserved on the PLC. The fields are used by both the PLC and by the plug-in to write and read the required data. The fields can be separated into two blocks on the PLC's memory. One block of fields is used by the PLC to request commands or to define arguments for the execution. The other block is used by the plug-in to write information provided by the vision system, for example, general information on the vision system or the results of an execution. The PLC can read and process the information provided in the fields that are written by the plug-in and vice versa. Each field has a predefined name.
Some of the fields are a fixed part of the setup and will always be provided, for example, the field containing the current state of the vision system. We will refer to these type of fields as static fields. In contrast, there are also some dynamic fields which depend on the configuration of the plug-in and are provided only if the respective parameters of the plug-in are set accordingly, for example, the fields for result values. In the following sections, you can find an overview of the static fields which are a fixed part in the protocol and the dynamic fields which are added only if the plug-in is configured accordingly.
Exporting the Fields for the PLC
The set of fields can be exported in the "Communication" tab of the MERLIC RTE Setup.
- Select the desired MELSEC Communication plug-in instance on the left to show the configuration of the plug-in.
- If necessary, adjust the location and file name of the .csv file to be exported. The respective parameters are provided in the parameter category Global Label CSV Export.
- Click on the "
Start plug-in" button on the bottom of the MERLIC RTE Setup to export the fields to the specified .csv file.
The .csv file will be exported automatically as soon as the plug-in is started, that is, as soon as you click on the start button. It contains information on all required fields, the respective data type, and the assigned memory addresses. The file can be created independently of the PLC. A connection to the PLC is not required for the export. However, if the connection is not established yet, an error message occurs that the plug-in could not be started. You can ignore this error if you only wanted to export the .csv file.
When implementing the program for the PLC in GX Works2, the exported file serves as input which fields and memory blocks are required for the communication. For this, you can imported the file as described in the next section.
Importing the "Global Label" File
After exporting the selected fields of your plug-in configuration to a "Global Label" .csv file, you can import this file in GX Works and use the respective fields for the implementation of the PLC program.
For our documentation, we make use of GX Works2 version 1.612N. If you are using GX Works3 or a different version of GX Works2, the user interface and parameter names might differ from the ones that are visible in our example images. For information on GX Works in general, its features, and how to work with GX Works to program and monitor MELSEC Series PLCs, please refer to the website of Mitsubishi Electric.
In GX Works2, you can import the file as described in the following steps.
- Open the "Project" panel.
- Right-click on the "Global Label" and select the menu entry "Read from CSV File...".

Static Fields
This type of fields are always available for the communication. Most of them are written by the plug-in to provide information on the vision system or on the current execution. The PLC writes only a few of the static fields.
Static Fields Written by Plug-in
|
Field |
Data type |
Description |
|---|---|---|
|
gMV_VersionMajor |
WORD |
Major version number of the plug-in. |
|
gMV_VersionMinor |
WORD |
Minor version number of the plug-in. |
|
gMV_CurrentState |
INT |
Current state of the MERLIC, for example, 72 for "SingleExecution". For more information on the values of the different state and how they are encoded, see the section MERLIC States. |
|
gMV_LastResultId |
DWORD |
ID of latest result. |
|
gMV_NumberOfRecipes |
DINT |
Number of recipes that are available. |
|
gMV_PreparedRecipeIds |
ARRAY [0..31] OF BOOL |
Indicator which recipe is currently prepared. It contains an array in which each entry indicates whether the recipe corresponding to the index is currently prepared. This only works if 32 or fewer recipes are defined. In addition, only one recipe can be prepared when MERLIC is used. |
|
gMV_RunningJobId |
DWORD |
ID of the job that is currently running. |
|
gMV_AcquisitionDoneCount |
DWORD |
Number of image acquisitions that have been performed for the current job. Initially it is set to 0 which indicates that no images have been acquired yet. It is reset for each new job. |
|
gMV_AckCommandCode |
INT |
Code of the requested command that has been acknowledged last by the plug-in. |
|
gMV_ErrorCode |
DINT |
Numeric error code. It provides information on the nature of the error, the severity, and the affected component. For more information on how errors are returned, see the topic Error Handling. |
|
gMV_ErrorCause |
INT |
Code of the command that caused an error. It assumes the same numeric value as given in the "gMV_ReqCommandCode" and "gMV_AckCommandCode" fields. For more information on how errors are returned, see the topic Error Handling. |
|
gMV_DroppedResultCount |
DWORD |
Number of results that have been dropped when using the result mode "Dequeue from buffer". Initially, it is set to 0 and incremented for each result that has been dropped. 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, that is, the result which would have been dequeued next. |
|
gMV_ResultId |
DWORD |
ID of the currently displayed result. |
|
gMV_ResultRecipeId |
DINT |
ID of the recipe which produced the displayed result. |
|
gMV_ResultJobId |
DWORD |
ID of the which produced the displayed result. |
|
gMV_ResultState |
INT |
State of the displayed result:
|
Static Fields Written by PLC
|
Field |
Data type |
Description |
|---|---|---|
|
gMV_ReqCommandCode |
INT |
Code of the requested command. For more information on the available commands and their codes, see the topic Communication between Plug-in and PLC . |
|
gMV_CommandRecipeIdInUse |
BOOL |
Indicator whether the recipe that is defined in "gMV_CommandRecipeId" shall be used for the command requested in "gMV_ReqCommandCode". |
|
gMV_CommandRecipeId |
DINT |
ID of the recipe that will be used for the command requested in "gMV_ReqCommandCode" if the value of "gMV_CommandRecipeIdInUse" is set to TRUE. |
This type of fields are not provided by default. They are only added to the PLC memory if the plug-in is configured accordingly. Thus, the configuration of the plug-in determines which of the dynamic fields will be available for the communication. As with the static fields, some of the dynamic fields which are written by the plug-in and some others are written by the PLC. The following sections provide an overview of the dynamic fields.
Dynamic Fields Written by the Plug-in
|
Field |
Description |
|---|---|
|
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 serves as indicator for 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 two least significant bits of "gMV_ResultUseArray_INT" are TRUE, both results of data type INT are available. Available data types:
|
|
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. These type of fields will only be added to the PLC memory if the configuration of the plug-in is set accordingly 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, two fields for the result values will be added to the PLC memory: "gMV_Result_INT_0" and "gMV_Result_INT_1". |
Dynamic Fields Written by the PLC
|
Field |
Description |
|---|---|
|
gMV_ItParamUseArray_<TYPE> |
Indicator whether the recipe parameters of the respective data type shall be overwritten for the next execution by the values defined in the fields of the corresponding iteration parameters. It contains an array in which each bit serves as indicator for a specific iteration parameter 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 iteration parameter data type in the category Reading Data from PLC Memory. For example, if the plug-in parameter "INT (signed 16-bit integer) iteration parameter allocation" is set to 2, the field "gMV_ItParamUseArray_INT" will be added together with the fields "gMV_ItParam_INT_0" and gMV_ItParam_INT_1" for the values of the iteration parameters. If the first two bits of "gMV_ItParamUseArray_INT" are set to TRUE, the first two recipe values of data type INT will be overridden for the next execution with the values defined in "gMV_ItParam_INT_0" and gMV_ItParam_INT_1". |
|
gMV_ItParam_<TYPE>_<INDEX> |
Values for the iteration parameters of the respective data types. These type of fields will only be added to the PLC memory if the configuration of the plug-in is set accordingly in the category Reading Data from PLC Memory. For example, if the plug-in parameter "INT (signed 16-bit integer) iteration parameter allocation" is set to 2, two fields for the result values will be added to the PLC memory: "gMV_ItParam_INT_0" and "gMV_ItParam_INT_1". |
MERLIC States
When using the MELSEC Communication plug-in, the internal state of MERLIC is transmitted to the PLC via the field "gMV_CurrentState".
The byte that transmits the information about the current state is encoded as follows:
|
Bit field position |
Numeric value |
MERLIC state |
Description |
|---|---|---|---|
|
0 |
1 |
Preoperational |
If this bit is set to 1, MERLIC is in the state "Preoperational". |
|
|
|
OperationalAutomaticMode Initialized Ready SingleExecution ContinuousExecution |
If this bit is set to 1, MERLIC is in the state "OperationalAutomaticMode". This means that MERLIC is either in the state "Initialized", "Ready", "SingleExecution", or "StartContinuous":
|
|
|
|
Halted |
If this bit is set to 1, MERLIC is in the state "Halted". |
|
|
|
Error |
If this bit is set to 1, MERLIC is in the state "Error". |
|
|
|
OperationalFrontendAccessMode |
If the 3rd and 8th bit are set, MERLIC is in the manual mode. This means that MERLIC can be controlled only via the MERLIC Frontend. For more information about the manual mode, see the topic Write Access in the Frontend in the MERLIC manual. |
For more information about the available states of MERLIC and its transitions, see the topic MERLIC States in the MERLIC manual.