Function Block - MODBUS-TCP Master (client).

This function block manages a client connection on MODBUS-TCP and enables the management of various MODBUS functions. Function blocks MBMASTERTCP and MBMASTERRTU give an alternative to the MODBUS configurator. You do not need to configure anything in the fieldbus configurator to use these blocks.

Inputs

Parameter

Description

Description

CNX

BOOL

A rising edge on this input establishes the connection with the specified server. Later on, if the connection is successful, the Ready output will be set to TRUE. If the connection fails, an error is reported by the Error output. After the connection is lost (typically when unplugging the Ethernet cable) the application is responsible for rising again the Cnx input in order to attempt a new connection.

SND

BOOL

A rising edge on this input starts a new exchange such as specified by other paramerters. A exchange can be started only if the Ready output is TRUE.

SLAVE

DINT

Slave number (or unit number) of the MODBUS TCP server.

FCODE

DINT

MODBUS function code. The following functions are supported:

1 = Read coil bits

2 = Read input bits

3 = Read holding registers

4 = Read input registers

5 = Write one coil bit

6 = Write one holding registers

7 = Read exception status

15 = Write N coil bits

16 = Write N holding registers

17 = Report slave ID

23 = Read/write holding registers

ADDR

DINT

Address of the first address to read. Used only for functions 1, 2, 3, 4 and 23.

NBR

DINT

Number of items to read. Used only for functions 1, 2, 3, 4 and 23.

ADDW

DINT

Address of the first address to write. Used only for functions 5, 6, 15, 16 and 23.

NBW

DINT

Number of items to write. Used only for functions 5, 6, 15, 16 and 23. Must be 1 for functions 5 and 6.

DATA

ARRAY OF ...

Buffer containing the values read or written. Must be set on input before calling functions 5, 6, 15, 16 and 23. Filled on for other functions and also for function 23. The dimension of the array must be greater than or equal to the specified number of items. The data type of the array depends on the function:

BOOL for functions 1, 2, 5 and 15

INT or UINT or WORD for functions 3, 4, 6, 16 and 23

SINT or USINT or BYTE for functions 7 and 17.

 

TIMEOUT

TIME

Communication timeout for the complete exchange.

IP

STRING

IP address of the MODBUS server.

PORT

DINT

TCP port number of the server (usually 502).

Outputs

Parameter

Description

Description

READY

BOOL

This output is TRUE when the connection is correctly established and no pending exchange is currently running.

OK

BOOL

This output is set to TRUE at the end of a successful exchange. It is reset to FALSE when a new exchange is started.

ERROR

DINT

Error report. Can be one of the following values:

1 = invalid function code
2 = bad address
3 = bad value
4 = server failed
5 = server acknoledge
6 = server is busy
8 = data parity error
10 = gateway bad path
11 = gateway target failed
128 = timeout on exchange
129 = bad CRC
130 = ETHERNET/TCP error
200 = invalid slave number
201 = invalid MODBUS address
202 = invalid number of items or DATA array too small
203 = invalid type for DATA array
204 = invalid numner of items

Note: some devices may answer some other specific error reports

MBMasterTCP

IEC 61131-3 Automation platform > Drivers - Fieldbus configuration > MODBUS Master > Driver-specific information > Driver specific function blocks > MBMasterTCP

Previous chapterNext chapter


Created with the Personal Edition of HelpNDoc: Effortlessly create a professional-quality documentation website with HelpNDoc