PFC200 Modbus TCP Master: Unstable connection when accessing multiple RTU devices behind TCP/RTU gateway – how to handle Unit-IDs correctly?

Hello everyone,

I am working with a WAGO PFC200 (750-8212) as Modbus TCP Master and I am experiencing unstable connections when communicating with multiple Modbus RTU devices behind a TCP/RTU gateway.

Setup

  • Controller: WAGO PFC200

  • Modbus TCP Master (CODESYS)

  • Gateway: Waveshare RS485 → Ethernet (Modbus TCP to RTU)

  • Field devices: several Growatt inverters on one RS485 bus

  • Each inverter has its own Modbus RTU address

  • Communication via one IP / one port

For comparison:

  • Node-RED running on a separate system (not on the PFC200) communicates stably with the same gateway and devices. (Only for testing purpose, Scrrenshot was taken when NODE-RED was stopped)

Observed behavior

With the PFC200 I tried to configure one Modbus TCP Slave per inverter.

This allows communication, but results in:

  • multiple parallel TCP connections to the same gateway

  • frequent reconnects and dropped connections

  • unstable long-term operation

I am trying to understand what the correct or recommended approach is in this situation.

Questions

  • How should multiple RTU devices behind a TCP/RTU gateway be addressed using the WAGO Modbus TCP Master?

  • Is it expected to use multiple Modbus TCP Slave objects, or a single one?

  • How are Modbus RTU addresses (Unit-IDs) intended to be handled in such a setup?

  • Are there any best practices for achieving a stable connection in this scenario?

I wanted to include more screenshots, but since I´m new to wago I can´t include more.

Thanks a lot for any hints or guidance.

Best regards

Moritz

For one RTU-line use one TCP-client. Otherwise, parallel requests from multiple clients are queued inside the gateway, leading to response delays and “unstable communication”.

Hi,

you can manully program a queue/joblist like here, or use the digital twin like here.

Thank you for your reply.

How can multiple Modbus slave IDs be addressed when using a Modbus TCP client?

Is there any example or documentation available that demonstrates this setup?

Hi,

    Jobliste: ARRAY [0..1] OF typMbQuery := [ 
        ( //JOB 0, read inputs
            bUnitId:= 1, 
            bFunctionCode:= 3, 
            uiReadAddress:= 0, 
            uiReadQuantity:= 30,    // read the first 30 registers?
            uiWriteAddress:= 0, 
            uiWriteQuantity:= 0, 
            awWriteData:= [125(0)]
        ),
        ( //JOB 1, write outputs (register access)
            bUnitId:= 1, 
            bFunctionCode:= 16, 
            uiReadAddress:= 0, 
            uiReadQuantity:= 0, 
            uiWriteAddress:= 0, 
            uiWriteQuantity:= 1, 
            awWriteData:= [125(0)]
        )];

With bUnitId you define the slave address. With each request you can set different ID.

You have to configure your gateway to forward this ID as address.

There are two types of gateways that I have seen. Some will forward the unit ID, others will use different TCP ports for different slave addresses. The latter one you cannot use with this code example. Some of the gateways you can configure for both methods.

1 Like