我们今天能为您提供什么帮助?

How do I write Modbus data from a Modicon M340 to a serial Modbus device through a TSXETG100 Ethernet gateway using WRITE_VAR?

Issue

How to configure a Modicon M340 application to write Modbus data to a serial Modbus device through a TSXETG100 Ethernet gateway using the ADDM and WRITE_VAR function blocks.

Product Line

  • Modicon M340
  • TSXETG100 Ethernet gateway
  • Unity Pro

Environment

The procedure applies to an architecture where a Modicon M340 communicates over Ethernet with a TSXETG100, which provides access to a Modbus serial device.

Example values used in this FAQ:

  • Ethernet network link: Ethernet_1
  • TSXETG100 IP address: 192.168.40.2
  • Modbus serial device address: 49

Resolution

1. Configure the Ethernet network in Unity Pro

  1. Open the Unity Pro project.
  2. Create a new Ethernet network.
  3. Configure the Ethernet network according to the application requirements.

ethernet, configuration, channel

  1. Validate the configuration.
  2. Link the Ethernet network to the appropriate Ethernet port in the PLC configuration.

link , M340, ethernet

2. Configure the project settings

  1. Select Tools > Project Settings.
  2. In the Data Types settings, enable the last three available options.

These settings allow arrays to be entered directly in the application instead of requiring them to be declared as variables.

The exact names of these three settings are not provided in the source information and should be verified before publication.

project setting, unity pro

3. Configure the TSXETG100

  1. Connect to the TSXETG100 web pages.
  2. Log in using credentials appropriate for the device.
  3. Open Clock Setup, then Serial Port.
  4. Configure the serial communication parameters according to the Modbus serial network.

serial port , configuration

  1. Open Device List and verify that the target serial device is listed.

Device list, configuration

  1. Open Ethernet & TCP/IP and configure the Ethernet interface according to the network configuration.

TCP configuration

4. Configure the ADDM and WRITE_VAR blocks

Add an ADDM block to the Unity Pro application.

Connect the OUT output of the ADDM block to the ADR input of the WRITE_VAR block.

Configure the IN input of ADDM with the address string corresponding to the Ethernet network, TSXETG100 IP address, and Modbus serial device address.

For the example in this FAQ:

  • Network link: Ethernet_1
  • TSXETG100 IP address: 192.168.40.2
  • Modbus serial device address: 49

The IN parameter is a string. The address must therefore be entered using the string syntax supported by Unity Pro.

The original case does not provide the complete ADDM address string. Refer to the applicable ADDM Ethernet addressing documentation or FAQ for the exact syntax.

Configure the remaining WRITE_VAR parameters:

  • OBJ: String identifying the object type to write, such as %MW or %M.
  • NUM: Starting address in the target Modbus device.
  • NB: Number of objects/registers to write.
  • GEST: Four-element array used as the exchange management table for WRITE_VAR.
  • EMIS: Array containing the data to be written. Its required size depends on NB and the object type being transferred.

When applicable, arrays declared as variables are of type INT.

WRITE_VAR, code, example, M340, ADDM

5. Build and download the application

  1. Build the Unity Pro project.
  2. Download the application to the PLC.
  3. Run the application.
  4. Verify that the WRITE_VAR exchange completes successfully and that the expected data is written to the target Modbus serial device.

施耐德電機Taiwan

探索更多
產品:
探索更多
產品:
  • 產品文檔
  • 軟體下載
  • 產品選型工具
  • 產品替代和替換
  • 幫助和聯絡中心
  • 尋找我們的辦公室
  • 取得報價
  • 施耐德電機社群
  • 人才招募
  • 公司簡介
  • 舉報不當行為
  • 無障礙
  • 新聞中心
  • 投資者
  • 專業洞察
  • 台灣施耐德電機學院
  • 綠色影響力落差調查
  • Schneider Go Green 2025
  • 隱私政策
  • Cookie通告
  • 使用條款
  • Change your cookie settings