# ModbusClient\_TCP\_Fast

## `ModbusClient_TCP_Fast` (FB) <a href="#modbusclient_tcp_fast-fb" id="modbusclient_tcp_fast-fb"></a>

FUNCTION\_BLOCK ModbusClient\_TCP\_Fast EXTENDS ModbusClientBase

### Function description <a href="#funktionsbeschreibung" id="funktionsbeschreibung"></a>

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`                         | ‘’                                         | <p>Hostname (FQDN, e.g. '[www.focus.de](http://www.focus.de)') or IP address of the<br>server (e.g. '192.168.178.210') (Modbus-TCP)</p> |                  |
| Input       | `wPort`                 | `WORD`                           | 502                                        | <p>Port number of the server (Modbus-TCP) (502 is the default<br>port)</p>                                                              |                  |
| 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                                      | <p>Current standby state (FALSE = not ready, TRUE = ready to<br>send/receive Modbus data)</p>                                           |                  |
| Input Const | `tKeepAliveTimeout`     | `TIME`                           | TIME#1m20s0ms                              | <p>Time between the last packet sent and the first probe (<br>idle mode)</p>                                                            |                  |
| 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                                 | <p>Timeout for the client-server communication (resolve = name<br>resolution & connection time)</p>                                     |                  |
