ModbusClient_TCP_Fast

ModbusClient_TCP_Fast (FB)

FUNCTION_BLOCK ModbusClient_TCP_Fast EXTENDS ModbusClientBase

Function description

This function block implements the client functionalities in a Modbus-TCP communication The counterpart must implement the server functionalities. It was introduced to increase communication speed when handling a large number of Modbus telegrams. Ideally ( = complete reception of the Modbus response telegram within a task cycle time ) a new transmission is started cyclically after T = 3 * task cycle time ( T = 30ms with a task cycle time of 10ms ). For Modbus telegrams with a lot of data and/or low transmission rates on the serial side ( RS 485 ), this duration can increase accordingly.\

InOut:

Scope
Name
Type
Initial
Comment
Inherited from

Output

xConnected

BOOL

TRUE if connection has been established

ModbusClientBase

Output

xLicenceValid

BOOL

TRUE if a valid licence was found

ModbusClientBase

Input

xEn

BOOL

TRUE

Input to enable / disable the function block

Input

sHostAddress

STRING

‘’

Hostname (FQDN, e.g. 'www.focus.de') or IP address of the server (e.g. '192.168.178.210') (Modbus-TCP)

Input

wPort

WORD

502

Port number of the server (Modbus-TCP) (502 is the default port)

Input

xResetLastErrors

BOOL

FALSE

Input to reset the error outputs (rising edge)

Output

byLastRequestUnitID

BYTE

0

Last request telegram: Unit ID (0 = no unit)

Output

eState

Client_TCP_StateCode

Client_TCP_StateCode.IDLE

Current state of the state machine as ENUM

Output

eResponseState

Client_TCP_Response_StateCode

Client_TCP_Response_StateCode.NO_ERROR

Last response telegram: Description of the state as ENUM

Output

byLastErrorUnitID

BYTE

0

Last error: Unit ID (0 = no unit)

Output

xError

BOOL

FALSE

Current error state (FALSE = no error, TRUE = error)

Output

eLastErrorCode

Client_TCP_ErrorCode

Client_TCP_ErrorCode.NO_ERROR

Last error: Description of the communication error as ENUM

Output

xReady

BOOL

FALSE

Current standby state (FALSE = not ready, TRUE = ready to send/receive Modbus data)

Input Const

tKeepAliveTimeout

TIME

TIME#1m20s0ms

Time between the last packet sent and the first probe ( idle mode)

Input Const

tTimeoutDeviceReceive

TIME

TIME#2s0ms

Timeout for the device communication (read)

Input Const

tTimeoutDeviceSend

TIME

TIME#2s0ms

Timeout for the device communication (send)

Input Const

tTimeoutConnect

TIME

TIME#3s0ms

Timeout for the client-server communication (resolve = name resolution & connection time)

Last updated