Modbus TCP Communication

You are currently viewing the documentation for the latest version (2.2.1). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

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 (slave) and the PLC acts as the client (master). 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.
handshake-workflow

Input and Output Signals

Mech-MSR supports the following standard Modbus function codes for accessing holding registers.

Function code Description

0x03

Read holding registers

0x06

Write single holding register

0x10

Write multiple holding registers

Holding register addresses are logical (or display) addresses, such as 40001 and 40005. The prefix 4 indicates that the address belongs to the 4x address space, which corresponds to holding registers. The digits following the prefix represent the register number.

In actual Modbus TCP communication, the base address is 1, meaning that addresses start from 40001. However, the actual register address used in communication is calculated as follows: Actual Address = Display Address40001. For example, the display address 40001 corresponds to the actual address of 0, and 40005 corresponds to the actual address of 4.

Input (from the PLC to Mech-MSR) Output (from Mech-MSR to the PLC)

Module

Name

Bytes occupied

Holding register address (4x)

Module

Name

Bytes occupied

Holding register address (4x)

CONTROL_INPUT

Command enable

1 byte

40001

CONTROL_OUTPUT

Heartbeat

1 byte

40065

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

First byte: 40001; last two bytes: 40002

Overall judge

1 byte

40065

Reserved field

Reserved field

Reserved field

Reserved field

Reserved field

Reserved field

Reserved field

Reserved field

2 bytes

40066

COMMAND

Command code

2 bytes

40003

STATUS_CODE

Status code

2 bytes

40067

COMMAND_PARAM

Command parameter 1

2 bytes

40004

RESERVED

Reserved field

2 bytes

40068

Command parameter 2

2 bytes

40005

JUDGE

Judgment result of ID 1

Judgment result of ID 2

Judgment result of ID 3

...

8 bytes

40069–40072

Command parameter 3

2 bytes

40006

Command parameter 4

2 bytes

40007

Command parameter 5

2 bytes

40008

Command parameter 6

2 bytes

40009

VALUE

Measurement result of ID 1

Measurement result of ID 2

Measurement result of ID 3

...

256 bytes

(4 bytes × 64)

40073–40200

Command parameter 7

2 bytes

40010

Command parameter 8

2 bytes

40011

Command parameter 9

2 bytes

40012

Command parameter 10

2 bytes

40013

VAR_INPUT

Variable 1

4 bytes

40014–40015

Variable 2

4 bytes

40016–40017

Variable 3

4 bytes

40018–40019

Variable 4

4 bytes

40020–40021

Variable 5

4 bytes

40022–40023

Variable 6

4 bytes

40024–40025

Variable 7

4 bytes

40026–40027

Variable 8

4 bytes

40028–40029

Variable 9

4 bytes

40030–40031

Variable 10

4 bytes

40032–40033

RESERVED

Reserved field

62 bytes

40034–40064

Input (from the PLC to Mech-MSR)

CONTROL_INPUT

Address Data Description

0.0

Command enable (Boolean)

Only when the command enable signal is set to 1, other input signals take effect.

0.1

Command trigger (Boolean)

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 trigger acknowledge signal, the command trigger signal can be set to 0.

0.2

Data read finished (Boolean)

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 (Boolean)

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 (Boolean)

A reserved field.

0.5

Reserved field (Boolean)

A reserved field.

0.6

Reserved field (Boolean)

A reserved field.

0.7

Reserved field (Boolean)

A reserved field.

1.0–3.7

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).

Command 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

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.

recipe

6

Project ID, parameter recipe ID

Used to switch the parameter recipe used by the project.

solution

7

Solution ID.

Used to switch the solution.

SetNumVar

8

ID of a global variable. Only one ID can be set at a time.

Used to set values for global variables of numeric type. The value of the variable is passed through VAR_INPUT.

GetNumVar

9

ID of a global variable. Only one ID can be set at a time.

Used to read the value of a global variable of numeric type. The result is returned by VALUE.

VAR_INPUT

When SetNumVar is executed, the set value is set to VAR_INPUT.

Holding register address (4x) Data Description

40014–40015

Variable 1 (Float)

The numeric input parameter is 1.

40016–40017

Variable 2 (Float)

The numeric input parameter is 2.

40018–40019

Variable 3 (Float)

The numeric input parameter is 3.

40020–40021

Variable 4 (Float)

The numeric input parameter is 4.

40022–40023

Variable 5 (Float)

The numeric input parameter is 5.

40024–40025

Variable 6 (Float)

The numeric input parameter is 6.

40026–40027

Variable 7 (Float)

The numeric input parameter is 7.

40028–40029

Variable 8 (Float)

The numeric input parameter is 8.

40030–40031

Variable 9 (Float)

The numeric input parameter is 9.

40032–40033

Variable 10 (Float)

The numeric input parameter is 10.

Output (from Mech-MSR to the PLC)

CONTROL_OUTPUT

Address Data Description

0.0

Heartbeat (Boolean)

System heartbeat. It toggles every second. Used to determine whether the PLC and Mech-MSR are connected or disconnected.

0.1

Trigger acknowledge (Boolean)

When Mech-MSR receives the rising edge for the command trigger signal, this signal is set to 1. When a falling edge is detected for the command trigger signal, this signal is set to 0.

0.2

Data ready (Boolean)

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 (Boolean)

When the command execution completes, this signal is set to 1, which indicates that the command execution is completed.

0.4

Reserved field (Boolean)

A reserved field.

0.5

Reserved field (Boolean)

A reserved field.

0.6

Reserved field (Boolean)

A reserved field.

0.7

Error (Boolean)

If the status code returned by Mech-MSR is not 1, an error occurred and this signal is set to 1.

1.0

Overall judge (Boolean)

The overall judgement of the project. 1 indicates OK, and 0 indicates NG.

1.1–1.7

Reserved field (Boolean)

A reserved field.

2.0–3.7

Reserved field (Byte)

A reserved field.

STATUS_CODE

The possible returned status codes for Mech-MSR are as follows:

  • Normal status code: 1, indicating that the command was executed successfully.

  • Error codes: -1, -2, -3, -4, -5. For more information, see Error Codes.

JUDGE

Judgement results were added for measurement items on the Communication output tab in the Output Management window. 1 indicates OK, and 0 indicates NG.

At most 64 judgement results can be output for a single project at a time.

VALUE

The VALUE module returns the following data:

  • Measurement results are added for measurement items on the Communication output tab in the Output Management window.

  • The values of numeric global variables are read when theGetNumVarcommand is executed.

At most 64 measurement results can be output for a single project at a time.

Is this page helpful?

You can give a feedback in any of the following ways:

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.