-

Y_CO_ModbusTCPClient

Image

This function blocks enables the controller as a Modbus TCP client.

Parameters

* Parameter Data Type Description Default
VAR_IN_OUT
V ComData Yt_CO_TCP_UDT_COMMUNICATION Communication structure of the client block. This is used for troubleshooting and does not have to be managed by the user.
V FunctionCodeData Yt_CO_TCP_FC_Data This structure contains all the configuration information for the various function codes that the client plans to use. User has to manage this configuration.
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 functionblock is not reinitialized. FALSE
V Server_IP STRING This parameter specifies the IP address of the server device. STRING#''
V Port INT TCP port of the server device. Default is 502. INT#502
V BindIP STRING Defines the IP address of the client (controller) STRING#''
V BindPort UINT Port number of the client (controller) 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
V UpdateTime TIME Time delay between each cycle of function code request. See examples to understand the influence of Update time on cycle time for each function code. T#0s
VAR_OUTPUT
V Valid BOOL Indicates that the function is operating normally and the outputs of the function 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 when the client is connected to a server
V Status WORD Status of the connection. Please refer to notes for further details.
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 code to look up that error. This output is reset when 'Execute' or 'Enable' goes low.
V ErrMsg STRING Error message
V AddErrMsg STRING Additional error message
V Warning BOOL Set true, if one of the function codes encounters a warning. This does not interrupt the socket communication
V Message STRING If Warning is true, this output provides a message that describes that warning. This output is reset when 'Execute' or 'Enable' goes low.
V AddMessage STRING If Warning is true, this output provides this 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 response from the server

Error Description

See the Function Block ErrorID List.

Function Codes supported

  • Read
    • 01: Coils
    • 02: Discrete inputs
    • 03: Multiple holding registers
    • 04: Input registers
  • Write
    • 05: Single coil
    • 06: Single holding register
    • 15: Multiple coils
    • 16: Multiple holding registers


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

Connection Example with a SLIO Modbus TCP bus coupler

Enable the function code that need to be used to communicate with a server using the FunctionCodeData.FC<x>.Start variable. The quantity of data that needs to be requested should also be defined. Once this is set, the Client FB can be enabled and the client will start sending function code requests to the server device.

In the example shown below, the Modbus bus coupler supports FC4 and FC16.

Image

The program in iCubeEngineer can be set up as follows. It can be seen how FC16 and FC4 are being used to write and read registers.

Image

Connection Example with a GA500 over Modbus TCP using the SMP3 multiprotocol card

GA500 with the multiprotocol card set up for Modbus TCP. The SMP3 Option Card needs to be set to Modbus TCP/IP mode by setting the dipswitches on the card to the following settings:
Image


Image

The following VFD Parameters need to be set to communicate using the SMP3 card in ModbusTCP/IP mode
Set up the desired function codes as shown below. Enable the client FB. The client FB will establish connection with the server and start communicating.

Image

Connection Example with a GA800 over Modbus TCP using the SMP3 multiprotocol card

The SMP3 Option Card needs to be set to Modbus TCP/IP mode by setting the dipswitches on the card to the following settings:
Image

Image

The following VFD Parameters need to be set to communicate using the SMP3 card in ModbusTCP/IP mode
  • B1-01 (Frequency Reference Selection)
  • B1-02 (Run Command Selection)
  • F6-14 (Bus Error Auto Reset)
  • F7-01~F7-04 (IP Address)
  • F7-13 (Address Startup Mode)
Set up the desired function codes. Enable the client FB.

Image

Data Packet Timing Example

The client FB organizes data requests sequentially. In this example the client and connected server are running at a task rate of 4ms. Every function code that has the start bit TRUE is requested sequentially as shown below. One request is sent out every 28ms. The rate at which the data packets are requested is dependent on the task rate and the physical connection between client and server. The example below shows how the first function code request is repeated after an interval of 252 ms.

Image

The quantity of read/write variables does not affect this rate. So, if FC23, FC16, and FC15 are not necessary for the application those function codes can be disabled to increase the communication rate of the other function codes. In the example below, removing those function codes increases the execution rate of the remaining function codes from 252ms to 168ms. This improvement is predicable.
168ms = 252ms - (3)*28ms
Image

Update Time Example

Image


 


This help information is valid for iCube Engineer Online Help 2025.6

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