ModbusClient_TCP

ModbusClient_TCP (FB)

FUNCTION_BLOCK ModbusClient_TCP EXTENDS ModbusClientBase

Funktionsbeschreibung

Dieser Funktionsbaustein erfüllt die Client-Funktionalitäten in einer Modbus-TCP-Kommunikation. Die Gegenstelle muss die Server-Funktionalitäten erfüllen. Im Idealfall ( = Vollständiger Empfang des Modbus-Response-Telegramms innerhalb einer Task-Zykluszeitdauer ) wird zyklisch nach T = 5 * Task-Zykluszeitdauer ( T = 50ms bei einer Task-Zykluszeitdauer von 10ms ) eine neue Übertragung gestartet. Bei Modbus-Telegrammen mit vielen Daten und/oder geringen Übertragungsraten auf der seriellen Seite ( RS 485 ) kann sich diese Zeitdauer entsprechend erhöhen. 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 package 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 )

Zuletzt aktualisiert