-

Y_CO_ModbusTCPServer

This function block enables the controller as a Modbus TCP server and starts listening to a client.

Image

Parameters

* Parameter Data Type Description Default
VAR_IN_OUT
V Coils Yt_CO_TCP_ARR_X_0_65535 Array with 65535 words representing the holding registers. The address range is 0-65535.Function codes: 1 and 15
V Inputs Yt_CO_TCP_ARR_X_0_65535 Array with 65535 words representing the holding registers. The address range is 0-65535.Function codes: 2
V InputRegisters Yt_CO_TCP_ARR_W_0_65535 Array with 65535 words representing the holding registers. The address range is 0-65535.Function codes: 4
V HoldingRegisters Yt_CO_TCP_ARR_W_0_65535 Array with 65535 words representing the holding registers. The address range is 0-65535.Function codes: 3,6,16 and 23
VAR_INPUT
V Enable BOOL The function will continue to execute every scan while Enable is held high and there are no errors. FALSE
V Acknowledge BOOL Modbus timeouts and IP-errors are acknowledged. The function block is not reinitialized. FALSE
V BindIP STRING This parameter specifies the IP address of the server controller which listens for incoming connections. If this string is empty (= initial value of the parameter) or contains the value '0.0.0.0', the server listens at every Ethernet adapter of the controller. STRING#''
V BindPort INT Defines the local port number to which the created socket is bound (necessary for setting up TCP/TLS servers). The selected port number is used by the TCP/TLS server for incoming data. Clients, which want to connect to this server, have to specify the same port number as their DEST_PORT input. If the value is 0 (= initial value of the parameter), the stack assigns a temporary port. INT#502
V DestIP STRING Only requests from the client with this IP address are accepted. If the string is empty (= initial value of the parameter), any client IP address is accepted. STRING#''
V DestPort INT Only requests from the client with this IP port are accepted. If the value is 0 (= initial value of the parameter), any client IP port is accepted. INT#0
V TimeOut TIME Timeout monitoring when there is a write access. After a write function was executed, a write telegram must be received again within the time specified here. A timeout error is reported if this is not the case. Specify the timeout value T#0s to disable this function. T#0s
VAR_OUTPUT
V Valid BOOL Indicates that the function block is operating normally and the outputs of the function block are valid.
V Busy BOOL Set high upon the rising edge of the Execute input, and reset when Done, CommandAborted, or Error is true. In the case of a function block with an Enable input, a Busy output indicates the function is operating, but not ready to provide Valid information. (No Error)
V Connected BOOL TRUE if the server is connected to a client.
V Status WORD Status of the connection. Please refer to the notes for detailed status word explanation.
V Error BOOL Set high if an error has occurred during the execution of the function block. This output is cleared when 'Execute' or 'Enable' goes low.
V ErrorID UINT If Error is true, this output provides the Error ID. This output is reset when 'Execute' or 'Enable' goes low.
V Message STRING If Error is true, this output provides the Error message. This output is reset when 'Execute' or 'Enable' goes low.
V AddErrMessage STRING If Error is true, this output provides any additional message. This output is reset when 'Execute' or 'Enable' goes low.


Notes


Status Description
16#0000 Function block is deactivated
16#8000 Function block is operating normally
16#8100 The block is waiting for a connection request from the client

Error Description

See the Function Block ErrorID List.

Supported Function Codes



Image


Object Type Access Size
Coil Read/Write 1 bit
Discrete input Read only 1 bit
Input registers Read only 16 bits
Holding registers Read/Write 16 bits

Starting Up a Server Connection Example

Once enabled, the Y_CO_ModbusTCPServer FB it will be listening for socket connection requests from a client. Once connected, the Valid and Connected outputs are TRUE. Status is 16#8000.

Image

Setting Up Multiple Servers Example

For each client a new TCP server needs to be instantiated.
Image
Image

If two clients have to share data on the server, the VAR_IN_OUT variables can be shared between the two instances that service each client.

Image

Modbus TCP Server response time

The Modbus TCPServer's response time to a function code is roughly between (2 x PLC task time where the Y_CO_ModbusTCPServer is running) and (3 x PLC task time where the Y_CO_ModbusTCPServer is running). Shown below is an example of data transfer when the Y_CO_ModbusTCPServer is running in an 8 ms task.

Image






 


This help information is valid for iCube Engineer Online Help 2025.6

Copyright © 2025 YASKAWA EUROPE GmbH and © 2025 YASKAWA America, Inc.