Getting the MVApp Results (Hilscher)

The process integration MERLIC can be used in machine vision systems that are integrated in a manufacturing machine. The machine controller, e.g., a programmable logic controller (PLC), must be able to control an integrated vision system, to monitor the execution, and to query the results. Therefore, MERLIC provides a process integration mode to enable the communication with a machine controller. The process integration mode can be started with the application "MERLIC RTE" that is provided with the MERLIC installation. mode of MERLIC does not return the results automatically. Instead, you have to query the results of the respective MERLIC Vision App (MVApp) iteration. The transmission of the results can be triggered with the command "GetResult". The respective command code is 2.

The command must be specified in the protocol FromPLCProtocol. In addition, you have to define the ID of the results you want to query in the member Selector. You can find the ID of the last result that was generated by MERLIC in the member LastResultId of the protocol FromMerlicProtocol.

Limitation

If the MVApp result that has been requested contains a tuple, only the value of the first tuple element is transmitted to the Hilscher card. The values of the other tuple elements cannot be accessed. Therefore, it is recommended to avoid defining tool results that might get tuple values as MVApp result when using a Hilscher card for the process integration.

Getting the Results

The following members must be set accordingly in the protocol FromPLCProtocol to query the results on a specific MVApp iteration:

Member

Value

Description

CommandCode

2

Define the code value 2 for the command "GetResult".

Selector

<Result ID>

Define the ID of the result whose value shall be returned. If no result with this ID exists, MERLIC changes to the "Error" state.

The protocol FromPLCProtocol that is sent from the PLC to MERLIC could be defined as shown in the following example:

Copy
TYPE
FromPLCProtocol :
STRUCT
    Preamble : 17;
    CommandCode : 2;
    Selector : 2;
END_STRUCT
END_TYPE

The value of CommandCode is set to 2. Therefore, MERLIC recognizes the command "GetResult". The result ID that is requested from the PLC is specified in the member Selector. In our example, the results with ID 2 are requested. MERLIC processes the command by looking up the values with result ID 2 and transmitting the respective values back to the PLC via the protocol FromMerlicProtocol.

The following example shows the protocol FromMerlicProtocol that is sent as response from MERLIC to the PLC. It contains the information about the requested results.

Copy
Preamble : 17
VersionMajor : 1
VersionMinor : 0
RecipeId : 1
CommandCode : 0
ActionResponse : 1
CurrentState : 34
LastResultId : 5
LastStartedJobId : 1
Reserved : 0
ResultState : 1
BoolCount : 0
ByteCount : 1
WordCount : 0
DWordCount : 0
LWordCount : 0
SIntCount : 0
USIntCount : 0
IntCount : 0
UIntCount : 0
DIntCount : 0
UDIntCount : 0
LIntCount : 0
ULIntCount : 0
RealCount : 0
LRealCount : 0
TimeCount : 0
TimeOfDayCount : 0
LTimeCount : 0
DateCount : 0
DateAndTimeCount : 0
Str80Count: 0
TotalResultCount : 1
DataIntegrity0 : 3
Result0 : 7

The value for Preamble indicates that the protocol begins with 17. The values for VersionMajor and VersionMinor indicate that the first version of the data protocol is used. The member RecipeId gives information that the input values defined in the recipe with the ID 1 have been used to parametrize the MVApp.

The CommandCode 0 is used to synchronize MERLIC and the PLC. In our example, this signals that MERLIC recognized and processed the command from the PLC that queries the results with the ID 2. The ActionResponse is set to 1 which means that the command was processed successfully. The value of CurrentState (34) indicates that MERLIC is currently in the state "Ready", that is, the bits for the states "Ready" and "OperationalAutomaticMode" are set. This means, it is ready to start a single operation, to query results of the last iteration, or to prepare a different recipe file.

In our example, the ID of the last results that have been calculated by MERLIC is 5, as transmitted for the member LastResultId. They were either calculated while running the job with ID 1, indicated by LastStartedJobId, or they were calculated in the previous job if the last started job with ID 1 did not produce any result yet. However, the PLC requested the results with the ID 2. Therefore, all results, that are transmitted to the PLC, have been calculated during the generation of the results with the ID 2. The value 1 for ResultState indicates that the processing was carried out correctly. The value of TotalResultCount contains the information that only one result has been returned with the requested LastResultId. The returned value is of the data type "Byte" which can be recognized by the value 1 for the member ByteCount. All other counters of the other data types are set to 0.

The actual information about the value of this result is stored in the members DataIntegrity and Result. The DataIntegrity of 3 is represented by the byte 00000011. The first bit indicates that the value is valid and the second bit indicates that the value has been determined in the MVApp iteration that generated the requested results with ID 2. For more information about the meaning of each bit, see Protocols for the Data Exchange. In the last entry of the protocol, the value of the result is returned. In our example, the result value is 7.