Modbus TCP Communication
Mech-MSR can communicate with external devices using the Modbus TCP protocol. Before you read the following content, make sure that the communication configuration has been completed in Mech-MSR.
About Modbus TCP
Mech-MSR can communicate with a PLC by using the Modbus TCP protocol. Under this communication mode, Mech-MSR acts as the server and the PLC acts as the client. All requests are initiated by the PLC and responded by Mech-MSR.
After the Modbus TCP communication is enabled in Mech-MSR, the software will begin listening for one or more Modbus clients on port 502 (the default listening port).
Communication Workflow
The workflow of Modbus TCP communication is shown in the figure below.
You can check the table in Input and Output Signals to learn the meaning of each signal. |
Input and Output Signals
Input (from the PLC to Mech-MSR) | Output (from Mech-MSR to the PLC) | ||||||
---|---|---|---|---|---|---|---|
Module |
Name |
Bytes occupied |
Holding register address |
Module |
Name |
Bytes occupied |
Holding register address |
Command enable |
1 byte |
0 |
Heartbeat |
1 byte |
0 |
||
Command trigger |
Trigger acknowledge |
||||||
Data read finished |
Data ready |
||||||
Reset |
Execution completed |
||||||
Reserved field |
Reserved field |
||||||
Reserved field |
Reserved field |
||||||
Reserved field |
Reserved field |
||||||
Reserved field |
Error |
||||||
Reserved field |
3 bytes |
1 |
Overall judge |
1 byte |
1 |
||
Reserved field |
|||||||
Reserved field |
|||||||
Reserved field |
|||||||
Reserved field |
|||||||
Reserved field |
|||||||
Reserved field |
|||||||
Reserved field |
|||||||
Reserved field |
2 bytes |
2 |
|||||
Command code |
2 bytes |
4 |
Status code |
2 bytes |
4 |
||
Command parameter 1 |
2 bytes |
6 |
RESERVED |
Reserved field |
2 bytes |
6 |
|
Command parameter 2 |
2 bytes |
8 |
Judgment result of ID 1 Judgment result of ID 2 Judgment result of ID 3 … |
8 bytes |
8 |
||
Command parameter 3 |
2 bytes |
10 |
|||||
Command parameter 4 |
2 bytes |
12 |
|||||
Measurement result of ID 1 Measurement result of ID 2 Measurement result of ID 3 … |
256 bytes (4 bytes × 64) |
16 |
Input (from the PLC to Mech-MSR)
CONTROL_INPUT
Address | Data | Description |
---|---|---|
0.0 |
Command enable (bool) |
Only when the command enable signal is set to 1, other input signals take effect. |
0.1 |
Command trigger (bool) |
When the command trigger signal changes from 0 to 1 (a rising edge is detected), Mech-MSR reads command codes and command parameters. When Mech-MSR returns the command trigger acknowledge signal, the command trigger signal can be set to 0. |
0.2 |
Data read finished (bool) |
When the PLC completes data reading, this signal can be set to 1. When the PLC is informed that the data ready signal changes to 0, this signal can be set to 0. |
0.3 |
Reset (bool) |
When this signal is set to 1, the PLC clears the received judgement result and measurement result. At this point, the PLC can send new commands and status code signals are reset. |
0.4 |
Reserved field (bool) |
A reserved field. |
0.5 |
Reserved field (bool) |
A reserved field. |
0.6 |
Reserved field (bool) |
A reserved field. |
0.7 |
Reserved field (bool) |
A reserved field. |
1.0 |
Reserved field (byte) |
A reserved field. |
COMMAND & COMMAND_PARAM
The following table describes the commands supported by the Modbus TCP communication, the command codes (COMMAND), and the command parameters (COMMAND_PARAM).
Commands | COMMAND | COMMAND_PARAM | Description |
---|---|---|---|
execute |
1 |
The project ID. Only one project ID can be set each time. |
Used to trigger the project and obtain project judgement result and measurement result. |
trigger |
2 |
The project ID. One to four project IDs can be set at a time. |
Used to trigger the project to run. |
return |
3 |
The project ID. Only one project ID can be set each time. |
Used to obtain the judgement result and the measurement result of the specified project. |
judge |
4 |
Used to obtain the overall quality judgment result of the specified project or the judgment results of individual measurement items. |
|
value |
5 |
Used to obtain the measured values of a specified project. |
You can check Project List of Mech-MSR to learn how to view the ID of a project. |
Output (from Mech-MSR to the PLC)
CONTROL_OUTPUT
Address | Data | Description |
---|---|---|
0.0 |
Heartbeat (bool) |
System heartbeat that flips every 1 second. Used to determine whether the PLC and Mech-MSR are connected or disconnected. |
0.1 |
Trigger acknowledge (bool) |
When Mech-MSR receives the rising edge for the command trigger signal, this signal is set to 1. When a failing edge is detected for the command trigger signal, this signal is set to 0. |
0.2 |
Data ready (bool) |
Mech-MSR writes data to output ports and waits for the PLC to read the output data. When the data read signal is set to 1, this signal is set to 0. |
0.3 |
Execution completed (bool) |
When the command execution completes, this signal is set to 1, which indicates that the command execution is completed. |
0.4 |
Reserved field (bool) |
A reserved field. |
0.5 |
Reserved field (bool) |
A reserved field. |
0.6 |
Reserved field (bool) |
A reserved field. |
0.7 |
Error (bool) |
If the status code returned by Mech-MSR is not 0, an error occurred and this signal will be set to 1. |
1.1 |
Overall judge (bool) |
The overall judgement of the project. 0 indicates OK, and 1 indicates NG. |
1.2~1.7 |
Reserved field (bool) |
A reserved field. |
STATUS_CODE
Five status codes may be returned by Mech-MSR:
-
Normal status code: 0, which indicates that the command has been successfully executed.
-
Error codes: –1, –2, –3 and –4. For more information, see Error Codes.
JUDGE
Judgement results were added for measurement items on the Communication output tab in the Output Management dialog box. 0 indicates OK, and 1 indicates NG.
At most 64 judgement results can be output for a single project at a time. |
VALUE
Measurement results are added for measurement items on the Communication output tab in the Output Management dialog box.
At most 64 measurement results can be output for a single project at a time. |