FB_ModbusTcpServer Functional Description

Overview

Type:

Function block

Available as of:

V1.0.0.0

Extends:

SE_CPT.FB_EnableReady

Functional Description

The function block is used to implement a Modbus TCP server in your application.

Interface

Input

Data type

Description

i_xEnable

BOOL

Enables the Modbus TCP server.

Refer to Behavior of Function blocks with the Input i_xEnable.

i_sInterfaceIp

STRING[15]

Specifies the IP address of the Ethernet interface the Modbus TCP server should monitor.

Enter a NULL string to monitor all Ethernet interfaces.

i_uiServerPort

UINT

Specifies the TCP port the server should monitor. If the input is not assigned, the default port 502 for Modbus TCP is applied. In this case, and if the controller is an M241, M251 or M262, an error will be detected instead.

i_stStartAddressConfig

ST_StartAddressConfig

Specifies the start addresses for the single data blocks provided by the Modbus TCP server.

i_axAppMemoryDiscreteInputs(1)

ARRAY OF BOOL(2)

Specifies the data block provided as discrete inputs by the Modbus TCP server. Data can be accessed (read only) by Modbus requests using the function code 0x02 (2).

i_axAppMemoryCoils(1)

ARRAY OF BOOL(2)

Specifies the data block provided as coils by the Modbus TCP server. Data can be accessed (read and write) by Modbus requests using the function codes 0x01 (1), 0x05 (5), and 0x0F (15).

i_awAppMemoryInputRegisters(1)

ARRAY OF WORD(2)

Specifies the data block provided as input registers by the Modbus TCP server. Data can be accessed (read only) by Modbus requests using function code 0x04 (4).

i_awAppMemoryOutputRegisters(1)

ARRAY OF WORD(2)

Specifies the data block provided as holding registers by the Modbus TCP server. Data can be accessed (read and write) by Modbus requests using the function codes 0x03 (3), 0x06 (6), 0x10 (16), and 0x17 (23).

(1) These inputs are optional. For each input which is not assigned, the server handles this type of the data model as not available.

(2) The specified data type is ANY. However, the documented type is the required data type which must be used for the variable assigned to this input.

Output

Data type

Description

q_xActive

BOOL

Indicates that the function block is active.

q_xReady

BOOL

Indicates that the Modbus TCP server is monitoring and incoming Modbus requests are processed.

q_xError

BOOL

If this output is set to TRUE, an error has been detected. For details, refer to q_etResult and q_sResultMsg.

To clear the error information, the function block must be reset.

This can be achieved by disabling and re-enabling the function block.

q_etResult

ET_Result

Provides diagnostic and status information as a numeric value.

q_sResultMsg

STRING [80]

Provides additional diagnostic and status information as a text message.

q_uiNumOfClients

UINT

Indicates the number of connected clients.