The leader in industrial automation and control solutions

Applicable Model(s)

cMT Series
cMT X Series

Title

Configuring Internal Modbus Communication Between a cMT’s EBPro and CODESYS Projects

Date

4/24/2025

Rev

Rev. 00

P/N

P/N: 0907-5157

Summary

It is possible for a cMT/cMT X series device configured with the Weintek Built-in CODESYS runtime to establish communication between the running EBPro and CODESYS projects on the device.

This is helpful if the CODESYS project must read/write certain values in HMI memory on the EBPro project, such as the dedicated System Registers. This method eliminates configuring Data Transfer objects or other actions in the EBPro project to access HMI memory.

Solution

The EBPro project must be configured to allow reading/writing of the necessary HMI memory registers via Modbus using the Modbus RTU/TCP Slave driver.

Meanwhile, the CODESYS project must be configured with an additional Ethernet device under the Weintek Built-in CODESYS device, and the necessary devices to connect to a Modbus server.


Configuring the EBPro Project

1.

Add the Modbus RTU/TCP Slave driver to the Device tab of the project’s System Parameter Settings and configure it to communicate via Ethernet.

2.

Enable the MODBUS TCP/IP Gateway option, and then select Address Mapping Tables.

3.

By default, HMI memory will be made accessible via specific Modbus address mappings (i.e., LB-0 ~ LB-12895 will be accessible as Modbus addresses 0x-0 ~ 0x-12895). Additional mappings can be created by selecting the Add button.

NOTE: Additional mappings are not created in this example. For additional information about using the Modbus Gateway and Address Mapping Table features, see the applicable chapters in the EBPro Manual.

Configuring the CODESYS Project

1.

In a CODESYS project, add an Ethernet device under an existing Weintek Built-in CODESYS device (referred to as “cMT CODESYS Interface”).

2.

Configure the Ethernet device to use the vnet1 interface (IP address 10.255.255.2). This is the internal LAN interface on a cMT to communicate with the CODESYS runtime.

3.

Add a Modbus TCP Client device under the Ethernet device (referred to as “Internal Modbus Client” in this example).

4.

Configure the Modbus TCP Client device to automatically reconnect upon connection loss.

5.

Add a Modbus TCP Server device under the Modbus TCP Client device (referred to as “cMT Modbus Gateway”).

6.

Configure the Modbus TCP Server device to use the cMT’s internal LAN IP address, 10.255.255.1, and set the TCP port for the Modbus server to the same as is configured in the cMT’s EBPro project (defaults to TCP port 502).

7.

Set the Unit ID to the station number of the Modbus server configured in the cMT’s EBPro project.

8.

Define channels within the Modbus TCP Server device. These will perform the appropriate Modbus polling commands to read/write register ranges on the cMT’s Modbus server.

This example shows a single channel configured to poll Modbus addresses on the cMT mapped to LW-0 ~ LW-9.

Note: When creating these channels, note that CODESYS IDE refers to Modbus addresses in hexadecimal format while EBPro refers to Modbus addresses in decimal format. What EBPro refers to as 4x-0010 will instead be 0x000A in CODESYS IDE.

9.

Map the newly created Modbus channels to variables of the appropriate length in the CODESYS project.

10.

Edit the CODESYS project to utilize the newly mapped variables. By default, the CODESYS project will not poll Modbus addresses unless they are used somewhere within executing POUs.

Once compiled, downloaded, and run on the cMT’s CODESYS runtime, values polled by the Modbus client in the CODESYS project will reflect the values of the HMI memory mapped to Modbus registers in the EBPro project.

LD logic used in this example first assigns the address of the polled array data to a pointer variable (cMT_LW100_ptr). The data referenced by the pointer is assigned to a variable storing the actual value (cMT_LW100_val):