Sie sind auf Seite 1von 85

Modbus_V1_xx Page 1 of 85

PC
Wor

Function Blocks of

Modbus_V1_xx

Library for the PC WorX Control


System

From Version 5.2


As of Nov 01, 2012

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 2 of 85

Table of contents
1 Introduction
1.1 General information
1.1.1 RTU
1.1.2 ASCII
1.2 List of function blocks
1.3 Call Examples
1.3.1 Controller is a Master
1.3.2 Controller is a Salve

2 MB_RTU485_Master_V1_xx block description


2.1 Block Data
2.2 Block Call
2.3 Input parameters
2.4 Output parameters
2.5 Input-Output Parameters
2.6 Diagnostics

3 MB_RTU_FCdynamic_V1_xx block description


3.1 Block Data
3.2 Block Call
3.3 Input parameters
3.4 Output parameters
3.5 Input-Output Parameters
3.6 Diagnostics

4 MB_RTU_FCn_V1_xx block description


4.1 Block Data
4.2 Block Call
4.3 Input parameters
4.4 Output parameters
4.5 Input-Output Parameters
4.6 Diagnostics

5 MB_RTU485_Slave_V1_xx block description


5.1 Block Data
5.2 Block Call
5.3 Input parameters
5.4 Output parameters
5.5 Input-Output Parameters
5.6 Diagnostics

6 MB_ASCII485_Master_V1_xx block description


6.1 Block Data
6.2 Block Call

7 MB_ASCII485_Slave_V1_xx block description


7.1 Block Data
7.2 Block Call

8 MB_RTU232_Master_V1_xx block description


8.1 Block Data
8.2 Block Call

9 MB_RTU232_Slave_V1_xx block description


9.1 Block Data

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 3 of 85

9.2 Block Call

10 MB_ASCII232_Master_V1_xx block description


10.1 Block Data
10.2 Block Call

11 MB_ASCII232_Slave_V1_xx block description


11.1 Block Data
11.2 Block Call

12 MB_RTUuni_Master_V1_01 description
12.1 Block Data
12.2 Block Call
12.3 Input parameters
12.4 Output parameters
12.5 Input-Output Parameters
12.6 Diagnostics

13 MB_RTUuni_Slave_V1_xx block description


13.1 Block Data
13.2 Block Call
13.3 Input parameters
13.4 Output parameters
13.5 Input-Output Parameters
13.6 Diagnostics

14 MB_ASCIIuni_Master_V1_xx block description


14.1 Block Data
14.2 Block Call

15 MB_ASCIIuni_Slave_V1_xx block description


15.1 Block Data
15.2 Block Call

16 Appendix A (Sending Requests from MB_RTU_FCdynamic_V1_xx)

17 Appendix B (MB_RTU_FCn_V1_xx blocks description)


17.1 Diagnostics
17.2 MB_RTU_FC01_V1_xx block description
17.2.1 Block Call
17.2.2 Input parameters
17.2.3 Output parameters
17.3 Input-Output Parameters
17.4 MB_RTU_FC02_V1_xx block description
17.4.1 Block Call
17.4.2 Input parameters
17.4.3 Output parameters
17.5 Input-Output Parameters
17.6 MB_RTU_FC03_V1_xx block description
17.6.1 Block Call
17.6.2 Input parameters
17.6.3 Output parameters
17.6.4 Input-Output Parameters
17.7 MB_RTU_FC04_V1_xx block description
17.7.1 Block Call
17.7.2 Input parameters
17.7.3 Output parameters

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 4 of 85

17.7.4 Input-Output Parameters


17.8 MB_RTU_FC05_V1_xx block description
17.8.1 Block Call
17.8.2 Input parameters
17.8.3 Output parameters
17.8.4 Input-Output Parameters
17.9 MB_RTU_FC06_V1_xx block description
17.9.1 Block Call
17.9.2 Input parameters
17.9.3 Output parameters
17.9.4 Input-Output Parameters
17.10 MB_RTU_FC07_V1_xx block description
17.10.1 Block Call
17.10.2 Input parameters
17.10.3 Output parameters
17.10.4 Input-Output Parameters
17.11 MB_RTU_FC08_V1_xx block description
17.11.1 Block Call
17.11.2 Input parameters
17.11.3 Output parameters
17.11.4 Input-Output Parameters
17.12 MB_RTU_FC11_V1_xx block description
17.12.1 Block Call
17.12.2 Input parameters
17.12.3 Output parameters
17.12.4 Input-Output Parameters
17.13 MB_RTU_FC12_V1_xx block description
17.13.1 Block Call
17.13.2 Input parameters
17.13.3 Output parameters
17.13.4 Input-Output Parameters
17.14 MB_RTU_FC15_V1_xx block description
17.14.1 Block Call
17.14.2 Input parameters
17.14.3 Output parameters
17.14.4 Input-Output Parameters
17.15 MB_RTU_FC16_V1_xx block description
17.15.1 Block Call
17.15.2 Input parameters
17.15.3 Output parameters
17.15.4 Input-Output Parameters
17.16 MB_RTU_FC20_V1_xx block description
17.16.1 Block Call
17.16.2 Input parameters
17.16.3 Output parameters
17.16.4 Input-Output Parameters
17.17 MB_RTU_FC21_V1_xx block description
17.17.1 Block Call
17.17.2 Input parameters
17.17.3 Output parameters
17.17.4 Input-Output Parameters
17.18 MB_RTU_FC22_V1_xx block description
17.18.1 Block Call
17.18.2 Input parameters
17.18.3 Output parameters
17.18.4 Input-Output Parameters
17.19 MB_RTU_FC23_V1_xx block description

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 5 of 85

17.19.1 Block Call


17.19.2 Input parameters
17.19.3 Output parameters
17.19.4 Input-Output Parameters
17.20 MB_RTU_FC24_V1_xx block description
17.20.1 Block Call
17.20.2 Input parameters
17.20.3 Output parameters
17.20.4 Input-Output Parameters

18 Example
18.1 Send Requests using MB_RTU_FCdynamic_V1_xx
18.1.1 Needed Blocks
18.1.2 Blocks layout
18.1.3 Activation
18.1.4 Putting Request Parameters
18.1.5 Sending Request using xSendRequest
18.1.6 Sending Request using polling
18.2 Send Requests using MB_RTU_FC3_V1_xx
18.2.1 Needed Blocks
18.2.2 Blocks layout
18.2.3 Activation
18.2.4 Putting Request Parameters
18.2.5 Sending Request using xSendRequest
18.2.6 Sending Request using polling
18.3 Sending Requests from different blocks

19 FAQ
19.1 Communication
19.2 Request and Responses

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 6 of 85

1 Introduction

1.1 General information


MODBUS is a communication protocol used mainly in serial interface. It is a Master-Slaves protocol. Only
one master (at the same time) is connected to the bus, and one or several (247 maximum number) slaves
nodes are also connected to the same serial bus.

A MODBUS communication is always initiated by the master. The master sends a request, then the
specified slave in the request responses. It is possible to send a request to all slaves (Broadcast mode).
The slave nodes will never transmit data without receiving a request from the master node. The slave
nodes will never communicate with each other. The master node initiates only one MODBUS transaction
at the same time.

There are four data types stored in a MODBUS device memory; discrete inputs (bits), coils (bits), holding
Register (16-bits registers) and input registers (16-bits registers).

Two MODBUS transmission modes are defined; RTU and ASCII.

1.1.1 RTU
RTU (Remote Terminal Unit) is the default transmission mode.
A MODBUS RTU telegram consists of slave address, function code, Data and CRC (Cyclic Redundancy
Check) value. The maximum telegram length is 256 bytes.

Figure 1: MODBUS RTU telegram frame.

Each byte is sent in an 11-bits frame, where a start bit, a stop bit and a parity bit are added.

Figure 2: Format of a Byte in MODBUS RTU mode.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 7 of 85

1.1.2 ASCII
When devices are setup to communicate on a MODBUS serial line using ASCII (American Standard Code
for Information Interchange) mode, each 8–bit byte in a message are sent as two ASCII characters. This
mode is less efficient than RTU since each byte needs two characters.

Figure 3: MODBUS ASCII telegram frame.

Figure 4: Format of a Byte in MODBUS RTU mode.

MODBUS could be implemented over RS485 or RS232 standards.

This Introduction is based on MODBUS standards in http://www.modbus.org/. More detailed information


and specifications are found there.

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 8 of 85

1.2 List of function blocks


The following table lists blocks used to configure the controller as a MODBUS master or slave.

Function block name Function


MB_RTU485_Master_V1_xx When the Controller acts as a Master, the block is
responsible for the communication with the serial
network.
Transmission mode: RTU
Serial Interface: RS485.
MB_RTU_FCdynamic_V1_xx A request can be sent using this function block. It
supports all function codes
It used to for all transmission modes and serial
interfaces
MB_RTU_FCn_V1_xx n represents function code. (For example: FC1, FC3…)
Each function code has it is own function block, with
which a request can be sent. The function block has
customised inputs in accordance with the used function
code.
It used to for all transmission modes and serial
interfaces
MB_RTU485_Slave_V1_02 The function block is used when controller acts as a
slave.
Transmission mode: RTU
Serial Interface:RS485
MB_ASCII485_Master_V1_01 When the Controller acts as a Master, the block is
responsible for the communication with the serial
network.
Transmission mode: ASCII
Serial Interface: RS485.
MB_ASCII485_Slave_V1_02 The function block is used when controller acts as a
slave.
Transmission mode: ASCII
Serial Interface:RS485
MB_RTU232_Master_V1_01 When the Controller acts as a Master, the block is
responsible for the communication with the serial
network.
Transmission mode: RTU
Serial Interface: RS232.
MB_RTU232_Slave_V1_02 The function block is used when controller acts as a
slave.
Transmission mode: RTU
Serial Interface: RS232
MB_ASCII232_Master_V1_01 When the Controller acts as a Master, the block is
responsible for the communication with the serial
network.
Transmission mode: ASCII
Serial Interface: RS232.
MB_ASCII232_Slave_V1_01 The function block is used when controller acts as a
slave.
Transmission mode: ASCII
Serial Interface: RS232
MB_RTUuni_Master_V1_01 When the Controller acts as a Master, the block is
responsible for the communication with the serial
network.
This function block is used with the universal module IB
IL RS UNI
Transmission mode: RTU
Serial Interface: RS485./ RS232
MB_RTUuni_Slave_V1_02 The function block is used when controller acts as a

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 9 of 85

slave.
This function block is used with the universal module IB
IL RS UNI
Transmission mode: RTU
Serial Interface: RS485./ RS232
MB_ASCIIuni_Master_V1_01 When the Controller acts as a Master, the block is
responsible for the communication with the serial
network.
It is used with the universal module IB IL RS UNI
Transmission mode: ASCII
Serial Interface: RS485./ RS232
MB_ASCIIuni_Slave_V1_02 The function block is used when controller acts as a
slave.
It is used with the universal module IB IL RS UNI
Transmission mode: ASCII
Serial Interface: RS485./ RS232
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 10 of 85

1.3 Call Examples

1.3.1 Controller is a Master


The MB_RTU_FCdynamic_V1_xx and MB_RTU_FCn_V1_xx are connected to the
MB_RTU485_Master_V1_xx function block through the parameter udtMBData.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 11 of 85

1.3.2 Controller is a Salve

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 12 of 85

2 MB_RTU485_Master_V1_xx block description


The block controls the connection between the controller and physical serial network (slaves). It receives
request from MB_RTU_FCdynamic_V1_xx or MB_RTU_FCn_V1_xx, analyse it and then send it to slaves
through the IB IL RS 485/422-PRO module. It receives response from a slave, analyse it and then send it
back to the block that sent the request. Diagnostics and communication errors are shown in this function
block
One instance of this block is needed for each IB IL RS 485/422-PRO module. UP to 32 instances from the
FC blocks can be connected at the same time for one MB_RTU485_Master_V1_01 block.
Note: for hardware wiring please refer to the data sheet of IB IL RS 485/422-PRO module.

2.1 Block Data


Block name: MB_RTU485_Master
Block type: Function block
Version: 1.01
Author: FMA / SAF
Control system types: All

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 13 of 85

2.2 Block Call

2.3 Input parameters


Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
diBaudrate DINT The Baud rate can be specified freely up to 500000.
Standard values are 110, 300, 600, 1200, 1800,
2400, 4800, 9600, 19200, 38400
Recommended value is 19200.
bDataWidth BYTE Data width specification
Byte Data bits Even/odd Stop bit
0hex 7 Even 1
1hex 7 Odd 1
2hex 8 Even 1
3hex 8 Odd 1
4hex 8 None 1
5hex 7 None 1
6hex 7 Even 2
7hex 7 Odd 2
8hex 8 Even 2
9hex 8 Odd 2
Ahex 8 None 2
Bhex 7 None 2

Recommended value is 2 hex.


arr_Pd_In COM_ARR_B_1_12 Input process Data of the IB IL RS 485/422-PRO
module.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 14 of 85

2.4 Output parameters


Output parameters
Name Type Description
xReady BOOL True: the block is successfully initialised
and ready to operate (no Error).
False: there is an error or block is
inactivated
xBusy BOOL True when the block is busy/ used
xError BOOL True when there is an error in
communication; IB IL RS 485/422-PRO
module
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Additional diagnostic code.
UiNoOfRequests UINT No of sent requests
UiNoOfResponses UINT No of received responses
arr_PD_Out COM_ARR_B_1_12 Output process Data of the IB IL RS
485/422-PRO module.

2.5 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 15 of 85

2.6 Diagnostics
The following table contains diagnostic codes and their interpretations. Codes form C010 till C040
diagnose the IB IL RS 485/422-PRO module’s configuration and parameters
wDiagCode Meaning
0000hex Block is not active, after activation this code will still be shown till the first
telegram is executed
8000hex Block is active without errors
C010hex Wrong terminal connection
wAddDiagCode Meaning
FFFFhex Error in Bus system; process data are should be connected
C020hex Error in IB IL RS 485/422-PRO module’s Parameters
wAddDiagCode Meaning
0010hex Error in baudrate
0020hex Error in data width
0030hex Error in Protocol
0050hex Baud rate is less or equal zero
C030hex Error in Sending
wAddDiagCode Meaning
0010hex Timeout during sending
C040hex Error in Receiving
wAddDiagCode Meaning
0010hex Timeout during receiving

If there is an error in this block, then the block will reset itself automatically until error is gone.
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 16 of 85

3 MB_RTU_FCdynamic_V1_xx block description


Using this block, the request is configured and sent. Details of requests (function block inputs) are
different depending on the required function code. It is possible to have more than instance in the same
program.
The supported function codes are FC 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 15, 16, 17, 20, 21, 22, 23 and 24.

The block should have the same udtMBData of the MB_RTU485_Master_V1_xx block.
For more detail on how to configure request parameters please refer to appendix A.
It used to for all transmission modes and serial interfaces

3.1 Block Data


Block name: MB_RTU_FCdynamic
Block type: Function block
Version: 1.00
Author: FMA / SAF
Control system types: All

3.2 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 17 of 85

3.3 Input parameters


Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
iFunctionCode INT Function code
uiStartAddress UINT Starting address
iQuantityOfData INT Quantity of registers/ Bits for function codes
1,2,3 and 4. For other function codes, this
input is ignored
arr_wRequestData MB_RTU_arr_w_0_124 Request Data. Not all function codes need
this input
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block
sends requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

3.4 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy/ used
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
arr_wResponseData MB_RTU_arr_w_0_124 Response data received from slave

3.5 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

Notes:
The xDone and xError indicates completion of send-receive process. It stays true till the xSendRequest input is
set to false. In case of polling, the response result (xDone and xError) are set for one cycle, then the next
request will be executed.
If more than one request is sent at the same time from different instances, then they will be executed one
after the other.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 18 of 85

3.6 Diagnostics
The following table contains diagnostic codes and their interpretations.
wDiagCode Meaning
0001hex Exception Code1,illegal function
0002hex Exception Code2,illegal data address
0003hex Exception Code3,illegal data Value
0004hex Exception Code4,Slave device failure
0005hex Exception Code5,Acknowledge
0006hex Exception Code6,Slave device Busy
0008hex Exception Code8,Memory parity error
000Ahex Exception Code0A,Gateway path unavailable
000Bhex Exception Code0B,Gateway target device failed to respond
0010hex Timeout Error
0020hex Slave-Address is out of valid range
0021hex Function Code is out of valid range or not supported
0022hex Invalid quantity of coils/input bits
0023hex invalid quantity of input / holding registers
0024hex invalid quantity of outputs (FC15)
0025hex invalid quantity of registers (FC16)
0026hex Invalid Byte count for FC 20
0027hex invalid quantity to read (FC 23)
0028hex invalid quantity to write (FC 23)
0029hex different CRC values for Request und Response
0030hex Invalid response, this error may occur when master and slave are
communicating with different speed, or slave sends a non-Modbus
response

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 19 of 85

4 MB_RTU_FCn_V1_xx block description


Using this block, requests are configured and sent. Each FC has its own function block with customised
inputs. It is possible to have more than instance in the same program.
The block should have the same udtMBData of the MB_RTU485_Master_V1_xx block.
It used to for all transmission modes and serial interfaces
The n in (MB_RTU_FCn_V1_xx) stands for function code number. Supported function codes are:
1,2,3,4,5,6,7,8,11,12,15,16,20,21,22,23 and 24.

For each function code block, Responses are saved in a customised output structure.

4.1 Block Data


Block name: MB_RTU_FCn
Block type: Function block
Version: 1.02
Author: FMA / SAF
Control system types: All

MB_RTU_FC3_V1_xx is taken as an example of an MB_RTU_FCn_V1_xx function block. All the block


calls are described in appendix B.
Function Code 3 is used to read holding registers from slaves.

4.2 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 20 of 85

4.3 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address
uiNoOfRegisters UINT Quantity of registers
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

4.4 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC3 MB_RTU_arr_w_1_125 Response data received from slave

4.5 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

Notes:
The xDone and xError indicates completion of send-receive process. It stays true till the xSendRequest input is
set to false. In case of polling, the response result (xDone and xError) are set for one cycle, then the next
request will be executed.
If more than one request is sent at the same time from different instances, then they will be executed one
after the other.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 21 of 85

4.6 Diagnostics
The following table contains diagnostic codes and their interpretations.
wDiagCode Meaning
0001hex Exception Code1,illegal function
0002hex Exception Code2,illegal data address
0003hex Exception Code3,illegal data Value
0004hex Exception Code4,Slave device failure
0005hex Exception Code5,Acknowledge
0006hex Exception Code6,Slave device Busy
0008hex Exception Code8,Memory parity error
000Ahex Exception Code0A,Gateway path unavailable
000Bhex Exception Code0B,Gateway target device failed to respond
0010hex Timeout Error
0020hex Slave-Address is out of valid range
0021hex Function Code is out of valid range or not supported
0022hex Invalid quantity of coils/input bits
0023hex invalid quantity of input / holding registers
0024hex invalid quantity of outputs (FC15)
0025hex invalid quantity of registers (FC16)
0026hex Invalid Byte count for FC 20
0027hex invalid quantity to read (FC 23)
0028hex invalid quantity to write (FC 23)
0029hex different CRC values for Request und Response
0030hex Invalid response, this error may occur when master and slave are
communicating with different speed, or slave sends a non-Modbus
response
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 22 of 85

5 MB_RTU485_Slave_V1_xx block description


The function block enables the controller to act as a slave. It has arrays of data emulating registers and
bits as if it is real memory of a slave device.
The supported function codes are: 1, 2, 3, 4, 5, 6, 15 and 16.
Diagnostics and communication errors are shown in this function block
One instance of this block is needed for each IB IL RS 485/422-PRO module.
Note: for hardware wiring please refer to the data sheet of IB IL RS 485/422-PRO module.

5.1 Block Data


Block name: MB_RTU485_Slave
Block type: Function block
Version: 1.02
Author: FMA / SAF
Control system types: All

5.2 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 23 of 85

5.3 Input parameters


Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
diBaudrate DINT The Baud rate can be specified freely up to 500000.
Standard values are 110, 300, 600, 1200, 1800,
2400, 4800, 9600, 19200, 38400
Recommended value is 19200.
bDataWidth BYTE Data width specification
Byte Data bits Even/odd Stop bit
0hex 7 Even 1
1hex 7 Odd 1
2hex 8 Even 1
3hex 8 Odd 1
4hex 8 None 1
5hex 7 None 1
6hex 7 Even 2
7hex 7 Odd 2
8hex 8 Even 2
9hex 8 Odd 2
Ahex 8 None 2
Bhex 7 None 2

Recommended value is 2 hex.


uiOffset UINT Address offset. For example if uiOffset is 2000,
then holding register 3 in udtHoldingRegisters
array will be address by 2003 (2000 + 3) in requests
instead of 3.
arr_Pd_In COM_ARR_B_1_12 Input process Data of the IB IL RS 485/422-PRO
module.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 24 of 85

5.4 Output parameters


Output parameters
Name Type Description
xReady BOOL True: the block is successfully initialised
and ready to operate (no Error).
False: there is an error or block is
inactivated
xBusy BOOL True when the block is busy/ used
UiNoOfTransactions UINT Number of processed transactions
xError BOOL True when there is an error in
communication; IB IL RS 485/422-PRO
module
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Additional diagnostic code.
arr_PD_Out COM_ARR_B_1_12 Output process Data of the IB IL RS
485/422-PRO module.

5.5 Input-Output Parameters


Input-Output Parameters
Name Type Description Function Code
udtHoldingRegisters MB_RTU_w_0_1999 Array of 2000 words 3, 6, and 16
representing holding
registers.
Their Address range is 0-
1999
udtInputRegisters MB_RTU_w_2000_2999 Array of 1000 words 4
representing input registers.
Their Address range is 2000-
2999
udtOutputBits MB_RTU_x_3000_3999 Array of 1000 bits 1, 5 and 15
representing output bits
(coils).
Their Address range is 3000-
3999
udtInputBits MB_RTU_x_4000_4999 Array of 1000 bits 2
representing input bits
Their Address range is 4000-
4999

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 25 of 85

5.6 Diagnostics
The following table contains diagnostic codes and their interpretations. Codes form C010 till C040
diagnose the IB IL RS 485/422-PRO module’s configuration and parameters
wDiagCode Meaning
0000hex Block is not active, after activation this code will still be shown till the first
telegram is executed
8000hex Block is active without errors
C010hex Wrong terminal connection
wAddDiagCode Meaning
FFFFhex Error in Bus system; process data are should be connected
C020hex Error in IB IL RS 485/422-PRO module’s Parameters
wAddDiagCode Meaning
0010hex Error in baudrate
0020hex Error in data width
0030hex Error in Protocol
0050hex Baud rate is less or equal zero
C030hex Error in Sending
wAddDiagCode Meaning
0010hex Timeout during sending
C040hex Error in Receiving
wAddDiagCode Meaning
0010hex Timeout during receiving

If there is an error in this block, then the block will reset itself automatically until error is gone.
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 26 of 85

6 MB_ASCII485_Master_V1_xx block description


This block functions exactly as MB_RTU485_Master_V1_xx function block, however it is used in ASCII
transmission mode.
For parameters configuration and diagnostics, please refer to MB_RTU485_Master_V1_xx function block.
Important: ASCII is less efficient than RTU since each byte needs two characters (two bytes). In addition
this function block is valid for data less than 330 characters due to hardware limitations.

6.1 Block Data


Block name: MB_ASCII485_Master
Block type: Function block
Version: 1.01
Author: FMA / SAF
Control system types: All

6.2 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 27 of 85

7 MB_ASCII485_Slave_V1_xx block description


This block functions exactly as MB_RTU485_Slave_V1_xx function block, however it is used in ASCII
transmission mode.
For parameters configuration and diagnostics, please refer to MB_RTU485_Slave_V1_xx function block.

Important: ASCII is less efficient than RTU since each byte needs two characters (two bytes). In addition
this function block is valid for data less than 330 characters due to hardware limitations.

7.1 Block Data


Block name: MB_ASCII485_Slave
Block type: Function block
Version: 1.02
Author: FMA / SAF
Control system types: All

7.2 Block Call

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 28 of 85

8 MB_RTU232_Master_V1_xx block description


This block functions exactly as MB_RTU485_Master_V1_xx function block, however it is used in RS232
serial communication.
For parameters configuration and diagnostics, please refer to MB_RTU485_Master_V1_xx function block.
Note: for hardware wiring please refer to the data sheet of IB IL RS 232-PRO module.

8.1 Block Data


Block name: MB_RTU232_Master
Block type: Function block
Version: 1.01
Author: FMA / SAF
Control system types: All

8.2 Block Call

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 29 of 85

9 MB_RTU232_Slave_V1_xx block description


This block functions exactly as MB_RTU485_Slave_V1_xx function block, however it is used in RS232
serial communication.
For parameters configuration and diagnostics, please refer to MB_RTU485_Slave_V1_xx function block.
Note: for hardware wiring please refer to the data sheet of IB IL RS 232-PRO module.

9.1 Block Data


Block name: MB_RTU232_Slave
Block type: Function block
Version: 1.02
Author: FMA / SAF
Control system types: All

9.2 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 30 of 85

10 MB_ASCII232_Master_V1_xx block description


This block functions exactly as MB_RTU485_Master_V1_xx function block, however it is used in RS232
serial communication with ASCII transmission mode.
For parameters configuration and diagnostics, please refer to MB_RTU485_Master_V1_xx function block.

Important: ASCII is less efficient than RTU since each byte needs two characters (two bytes). In addition
this function block is valid for data less than 330 characters due to hardware limitations.

For hardware wiring please refer to the data sheet of IB IL RS 232-PRO module.

10.1 Block Data


Block name: MB_ASCII232_Master
Block type: Function block
Version: 1.01
Author: FMA / SAF
Control system types: All

10.2 Block Call

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 31 of 85

11 MB_ASCII232_Slave_V1_xx block description


This block functions exactly as MB_RTU485_Slave_V1_xx function block, however it is used in RS232
serial communication withASCII transmission mode.
For parameters configuration and diagnostics, please refer to MB_RTU485_Slave_V1_xx function block.
Important: ASCII is less efficient than RTU since each byte needs two characters (two bytes). In addition
this function block is valid for data less than 330 characters due to hardware limitations.
For hardware wiring please refer to the data sheet of IB IL RS 232-PRO module.

11.1 Block Data


Block name: MB_ASCII232_Slave
Block type: Function block
Version: 1.02
Author: FMA / SAF
Control system types: All

11.2 Block Call

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 32 of 85

12 MB_RTUuni_Master_V1_01 description
The block controls the connection between the controller and physical serial network (slaves). It receives
request from MB_RTU_FCdynamic_V1_xx or MB_RTU_FCn_V1_xx, analyse it and then send it to slaves
through the IB IL RS UNI module. It receives response from a slave, analyse it and then send it back to
the block that sent the request. Diagnostics and communication errors are shown in this function block
One instance of this block is needed for each IB IL RS UNI module. UP to 32 instances from the FC
blocks can be connected at the same time for one MB_RTUuni_Master_V1_01 block.
Note: for hardware wiring please refer to the data sheet of IB IL RS UNI module.

12.1 Block Data


Block name: MB_RTUuni_Master
Block type: Function block
Version: 1.01
Author: FMA / SAF
Control system types: All with PC WORX 6.xx and higher

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 33 of 85

12.2 Block Call

12.3 Input parameters


Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
bSelectMode BOOL Transmission mode selection.
0 = RS 232, 1 = RS485
diBaudrate DINT The Baud rate can be specified freely up to 500000.
Standard values are 110, 300, 600, 1200, 1800,
2400, 4800, 9600, 19200, 38400
Recommended value is 19200.
bDataWidth BYTE Data width specification
Byte Data bits Even/odd Stop bit
0hex 7 Even 1
1hex 7 Odd 1
2hex 8 Even 1
3hex 8 Odd 1
4hex 8 None 1
5hex 7 None 1
6hex 7 Even 2
7hex 7 Odd 2
8hex 8 Even 2
9hex 8 Odd 2
Ahex 8 None 2
Bhex 7 None 2

Recommended value is 2 hex.


arr_Pd_In MB_RSUNI_ARR_B_1_14 Input process Data of the IB IL RS UNI module.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 34 of 85

12.4 Output parameters


Output parameters
Name Type Description
xReady BOOL True: the block is successfully initialised
and ready to operate (no Error).
False: there is an error or block is
inactivated
xBusy BOOL True when the block is busy/ used
xError BOOL True when there is an error in
communication; IB IL RS UNI module
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Additional diagnostic code.
UiNoOfRequests UINT No of sent requests
UiNoOfResponses UINT No of received responses
arr_PD_Out MB_RSUNI_ARR_B_1_14 Output process Data of the IB IL RS UNI
module.

12.5 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 35 of 85

12.6 Diagnostics
The following table contains diagnostic codes and their interpretations. Codes form C010 till C040
diagnose the IB IL RS UNI module’s configuration and parameters
wDiagCode Meaning
0000hex Block is not active, after activation this code will still be shown till the first
telegram is executed
8000hex Block is active without errors
C010hex Faulty Parameter
wAddDiagCode Meaning
0010hex Error in baudrate
0020hex Error in data width
0030hex Error in Protocol
0040hex Error in Transmission mode
0050hex Configuration error
0060hex Communication error
C020hex Error in Sending
wAddDiagCode Meaning
0010hex Timeout during sending
0020hex Maximal length is exceeded
0060hex Communication error during sending
C030hex Error in Receiving
wAddDiagCode Meaning
0010hex Timeout during receiving
0030hex uiRcvLength is larger than the available received data
0060hex Communication error during receiving

If there is an error in this block, then the block will reset itself automatically until error is gone.
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 36 of 85

13 MB_RTUuni_Slave_V1_xx block description


The function block enables the controller to act as a slave. It has arrays of data emulating registers and
bits as if it is real memory of a slave device.
Diagnostics and communication errors are shown in this function block
One instance of this block is needed for each IB IL RS UNI module.
Note: for hardware wiring please refer to the data sheet of IB IL RS UNI module.

13.1 Block Data


Block name: MB_RTUuni_Slave
Block type: Function block
Version: 1.02
Author: FMA / SAF
Control system types: All with PC WORX 6.xx and higher

13.2 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 37 of 85

13.3 Input parameters


Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
bSelectMode BOOL Transmission mode selection.
0 = RS 232, 1 = RS485
diBaudrate DINT The Baud rate can be specified freely up to 500000.
Standard values are 110, 300, 600, 1200, 1800,
2400, 4800, 9600, 19200, 38400
Recommended value is 19200.
bDataWidth BYTE Data width specification
Byte Data bits Even/odd Stop bit
0hex 7 Even 1
1hex 7 Odd 1
2hex 8 Even 1
3hex 8 Odd 1
4hex 8 None 1
5hex 7 None 1
6hex 7 Even 2
7hex 7 Odd 2
8hex 8 Even 2
9hex 8 Odd 2
Ahex 8 None 2
Bhex 7 None 2

Recommended value is 2 hex.


uiOffset UINT Address offset. For example if uiOffset is 2000,
then holding register 3 in udtHoldingRegisters
array will be address by 2003 (2000 + 3) in requests
instead of 3.
arr_Pd_In MB_RSUNI_ARR_B_1_14 Input process Data of the IB IL RS UNI module.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 38 of 85

13.4 Output parameters


Output parameters
Name Type Description
xReady BOOL True: the block is successfully initialised
and ready to operate (no Error).
False: there is an error or block is
inactivated
xBusy BOOL True when the block is busy/ used
UiNoOfTransactions UINT Number of processed transactions
xError BOOL True when there is an error in
communication; IB IL UNI module
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Additional diagnostic code.
arr_PD_Out MB_RSUNI_ARR_B_1_14 Output process Data of the IB IL RS UNI
module.

13.5 Input-Output Parameters

Input-Output Parameters
Name Type Description Function Code
udtHoldingRegisters MB_RTU_w_0_1999 Array of 2000 words 3, 6, and 16
representing holding
registers.
Their Address range is 0-
1999
udtInputRegisters MB_RTU_w_2000_2999 Array of 1000 words 4
representing input registers.
Their Address range is 2000-
2999
udtOutputBits MB_RTU_x_3000_3999 Array of 1000 bits 1, 5 and 15
representing output bits
(coils).
Their Address range is 3000-
3999
udtInputBits MB_RTU_x_4000_4999 Array of 1000 bits 2
representing input bits
Their Address range is 4000-
4999

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 39 of 85

13.6 Diagnostics
The following table contains diagnostic codes and their interpretations. Codes form C010 till C040
diagnose the IB IL RS UNI module’s configuration and parameters

wDiagCode Meaning
0000hex Block is not active, after activation this code will still be shown till the first
telegram is executed
8000hex Block is active without errors
C010hex Faulty Parameter
wAddDiagCode Meaning
0010hex Error in baudrate
0020hex Error in data width
0030hex Error in Protocol
0040hex Error in Transmission mode
0050hex Configuration error
0060hex Communication error
C020hex Error in Sending
wAddDiagCode Meaning
0010hex Timeout during sending
0020hex Maximal length is exceeded
0060hex Communication error during sending
C030hex Error in Receiving
wAddDiagCode Meaning
0010hex Timeout during receiving
0030hex uiRcvLength is larger than the available received data
0060hex Communication error during receiving

If there is an error in this block, then the block will reset itself automatically until error is gone.
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 40 of 85

14 MB_ASCIIuni_Master_V1_xx block description


This block functions exactly as MB_RTUuni_Master_V1_xx function block, however it is used in ASCII
transmission mode.
For parameters configuration and diagnostics, please refer to MB_RTUuni_Master_V1_xx function block.
Important: ASCII is less efficient than RTU since each byte needs two characters (two bytes).

14.1 Block Data


Block name: MB_ASCIIuni_Master
Block type: Function block
Version: 1.01
Author: FMA / SAF
Control system types: All with PC WORX 6 and higher

14.2 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 41 of 85

15 MB_ASCIIuni_Slave_V1_xx block description


This block functions exactly as MB_RTUuni_Slave_V1_xx function block, however it is used in ASCII
transmission mode.
For parameters configuration and diagnostics, please refer to MB_RTUuni_Slave_V1_xx function block.

Important: ASCII is less efficient than RTU since each byte needs two characters (two bytes).

15.1 Block Data


Block name: MB_ASCIIuni_Slave
Block type: Function block
Version: 1.02
Author: FMA / SAF
Control system types: All with PC WORX 6 and higher

15.2 Block Call

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 42 of 85

16 Appendix A (Sending Requests from MB_RTU_FCdynamic_V1_xx)


As mentioned earlier the general rule is that any additional details to the request must be filled in the
arr_wRequestData array in the correct order; for instance for function code 15, quantity of outputs, byte
count and output values are filled in the arr_wRequestData respectively.
If a request does not need all the parameters, then they can be ignored and left unfilled
Requests configuration according to function code
Function Code Parameter Input
Function Code 1
Slave address uiSlaveAddress
Function Code iFunctionCode
Starting address uiStartingAddress
Quantity of iQuantityOfData
Outputs
Function Code 2
Slave address uiSlaveAddress
Function Code iFunctionCode
Starting address uiStartingAddress
Quantity of Inputs iQuantityOfData
Function Code 3
Slave address uiSlaveAddress
Function Code iFunctionCode
Starting address uiStartingAddress
Quantity of iQuantityOfData
registers
Function Code 4
Slave address uiSlaveAddress
Function Code iFunctionCode
Starting address uiStartingAddress
Quantity of iQuantityOfData
registers
Function Code 5
Slave address uiSlaveAddress
Function Code iFunctionCode
Starting address uiStartingAddress
Output Value arr_wRequestData[0], first word of the array
Function code 6
Slave address uiSlaveAddress
Function Code iFunctionCode
Starting address uiStartingAddress
Register Value arr_wRequestData[0], first word of the array
Function Code 7
Slave address uiSlaveAddress
Function Code iFunctionCode
Function Code 8
Slave address uiSlaveAddress
Function Code iFunctionCode
Sub-function code arr_wRequestData[0], first word of the
array
Data arr_wRequestData[1], second word of the
array
Function Code 11
Slave address uiSlaveAddress
Function Code iFunctionCode
Function Code 12
Slave address uiSlaveAddress
Function Code iFunctionCode

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 43 of 85

Function Code 15
Slave address uiSlaveAddress
Function Code iFunctionCode
Starting address uiStartingAddress
Quantity of outputs arr_wRequestData[0], first word of the array
Byte Count arr_wRequestData[1], second word of the
array (lower byte)
Output values Next words of the array,
for example if 20 outputs to be written, then
first 8 are in the higher byte of
arr_wRequestData[2], then the next 8 are in
the lower byte of Arr_wRequestData[2], and
the rest is in the higher byte of the
Arr_wRequestData[3] and so on.
Function Code 16
Slave address uiSlaveAddress
Function Code iFunctionCode
Starting address uiStartingAddress
Quantity of arr_wRequestData[0], first word of the array
registers
Byte Count arr_wRequestData[1], second word of the
array (lower byte)
registers values Next words of the array,
for example if 2 registers to be written, then
first one is in the arr_wRequestData[2], then
the second in the Arr_wRequestData[3] and
so on.
Function Code 17
Slave address uiSlaveAddress
Function Code iFunctionCode
Function Code 20
Slave address uiSlaveAddress
Function Code iFunctionCode
Byte Count arr_wRequestData[0], first word of the array
(lower byte)
Subrequests Next words of the array
Note: the reference type of a subrequest is
written in one word (lower byte)
Function Code 21
Slave address uiSlaveAddress
Function Code iFunctionCode
Request data arr_wRequestData[0], first word of the array
length (lower byte)
Sub requests Next words of the array
Note: the reference type of a subrequest is
written in one word (lower byte)
Function Code 22
Slave address uiSlaveAddress
Function Code iFunctionCode
Reference uiStartingAddress
address
AND mask arr_wRequestData[0], first word of the array
OR-Mask arr_wRequestData[1], second word of the
array
Function Code 23
Slave address uiSlaveAddress
Function Code iFunctionCode
Read starting arr_wRequestData[0], first word of the array

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 44 of 85

address
Quantity to read arr_wRequestData[1], second word of the
array
Write starting arr_wRequestData[2],third word of the array
address
Quantity to write arr_wRequestData[3], forth word of the
array
Write byte count arr_wRequestData[4], fifth word of the array
(lower byte)
Registers values Next words of the array
for example if 2 registers to be written, then
first one is in the arr_wRequestData[5], then
the second in the Arr_wRequestData[6] and
so on.
Function Code 24
Slave address uiSlaveAddress
Function Code iFunctionCode
FIFO pointer arr_wRequestData[0], first word of the array

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 45 of 85

17 Appendix B (MB_RTU_FCn_V1_xx blocks description)


In this appendix, each of the MB_RTU_FCn_V1_xx is described.
Notes:
The xDone and xError indicates completion of send-receive process. It stays true till the xSendRequest input is
set to false. In case of polling, the response result (xDone and xError) are set for one cycle, then the next
request will be executed.
If more than one request is sent at the same time from different instances, then they will be executed one
after the other.

17.1 Diagnostics
All MB_RTU_FCn_V1_xx have the same diagnostics. The following table contains diagnostic codes and
their interpretations.
wDiagCode Meaning
0001hex Exception Code1,illegal function
0002hex Exception Code2,illegal data address
0003hex Exception Code3,illegal data Value
0004hex Exception Code4,Slave device failure
0005hex Exception Code5,Acknowledge
0006hex Exception Code6,Slave device Busy
0008hex Exception Code8,Memory parity error
000Ahex Exception Code0A,Gateway path unavailable
000Bhex Exception Code0B,Gateway target device failed to respond
0010hex Timeout Error
0020hex Slave-Address is out of valid range
0021hex Function Code is out of valid range or not supported
0022hex Invalid quantity of coils/input bits
0023hex invalid quantity of input / holding registers
0024hex invalid quantity of outputs (FC15)
0025hex invalid quantity of registers (FC16)
0026hex Invalid Byte count for FC 20
0027hex invalid quantity to read (FC 23)
0028hex invalid quantity to write (FC 23)
0029hex different CRC values for Request und Response
0030hex Invalid response, this error may occur when master and slave are
communicating with different speed, or slave sends a non-Modbus
response
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 46 of 85

17.2 MB_RTU_FC01_V1_xx block description


This function block is used to read output bits.

17.2.1 Block Call

17.2.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address
uiNoOfCoils UINT Quantity of Coils (Discrete Outputs)
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 47 of 85

17.2.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC1 MB_RTU_arr_x_1_2000 Array of 2000 bits that contains the coils
value of the response.
For example if 3 coils are read, then the first
3 bits contain their values

17.3 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

17.4 MB_RTU_FC02_V1_xx block description


This function block is used to read input bits.

17.4.1 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 48 of 85

17.4.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address
uiNoOfInputBits UINT Quantity of discrete input bits
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

17.4.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC2 MB_RTU_arr_x_1_2000 Array of 2000 bits that contains the inputs
value of the response.
For example if 3 inputs are read, then the
first 3 bits contain their values.

17.5 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 49 of 85

17.6 MB_RTU_FC03_V1_xx block description


This function block is used to read holding registers.

17.6.1 Block Call

17.6.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address
uiNoOfRegisters UINT Quantity of registers
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 50 of 85

17.6.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC3 MB_RTU_arr_w_1_125 Array of 125 words contains the registers
value of the response.
For example if 3 registers are read, then the
first 3 words contain their values.

17.6.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

17.7 MB_RTU_FC04_V1_xx block description


This function block is used to read input registers.

17.7.1 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 51 of 85

17.7.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address
uiNoOfRegisters UINT Quantity of registers
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

17.7.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC4 MB_RTU_arr_w_1_125 Array of 125 words contains the registers
value of the response.
For example if 3 registers are read, then the
first 3 words contain their values.

17.7.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 52 of 85

17.8 MB_RTU_FC05_V1_xx block description


This function block is used to write single bit.

17.8.1 Block Call

17.8.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address
OutputValue BOOL Bit value: True or False
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 53 of 85

17.8.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors

17.8.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

17.9 MB_RTU_FC06_V1_xx block description


This function block is used to write a single register.

17.9.1 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 54 of 85

17.9.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address
wRegisterValue WORD Register value
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

17.9.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors

17.9.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 55 of 85

17.10 MB_RTU_FC07_V1_xx block description


This function block is used to read exception status.

17.10.1 Block Call

17.10.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 56 of 85

17.10.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process
is done. It is valid (remains true) as long as the
xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC7 MB_RTU_udtDataFC7 Parameter Type Description
Function INT Function code
OutputData Byte Output Data

17.10.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

17.11 MB_RTU_FC08_V1_xx block description


This function block is used to read diagnostics.

17.11.1 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 57 of 85

17.11.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
wSubFunction WORD Sub-function
wData WORD Data field
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

17.11.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process
is done. It is valid (remains true) as long as the
xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC8 MB_RTU_udtDataFC8 Parameter Type Description
SubFunction WORD SubFunction
value
Data WORD Data

17.11.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 58 of 85

17.12 MB_RTU_FC11_V1_xx block description


This function block is used to get communication event counter.

17.12.1 Block Call

17.12.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 59 of 85

17.12.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process
is done. It is valid (remains true) as long as the
xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC11 MB_RTU_udtDataFC11 Parameter Type Description
Status WORD Status
EventCount WORD Event count

17.12.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

17.13 MB_RTU_FC12_V1_xx block description


This function block is used to get communication event log.

17.13.1 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 60 of 85

17.13.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

17.13.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and ready to
operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process is
done. It is valid (remains true) as long as the
xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response data are
invalid. It is valid (remains true) as long as the
xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC12 MB_RTU_udtDataFC12 Parameter Type Description
Status WORD Status
EventCount WORD Event count
MessageCount WORD Message
count
Events MB_RTU_arr_b_0_63 Array of
bytes
contains 0-
64 events

17.13.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 61 of 85

17.14 MB_RTU_FC15_V1_xx block description


This function block is used to write multiple bits.

17.14.1 Block Call

17.14.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address
uiQuantityOfOutputs UINT Quantity of bits
udtOutputValue MB_RTU_arr_x_1_1968 Bits values
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block
sends requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 62 of 85

17.14.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors

17.14.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

17.15 MB_RTU_FC16_V1_xx block description


This function block is used to write multiple registers.

17.15.1 Block Call

17.15.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT Starting address

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 63 of 85

uiQuantityOfRegisters UINT Quantity of registers


udtRegisterValue MB_RTU_arr_w_1_123 Registers vlaues
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block
sends requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

17.15.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive
process is done. It is valid (remains true) as
long as the xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors

17.15.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 64 of 85

17.16 MB_RTU_FC20_V1_xx block description


This function block is used to read file record.

17.16.1 Block Call

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 65 of 85

17.16.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
NoOfSubRequests INT Number of subreqeusts
udtFC20SubRequests MB_RTU_udtFC20SubRequests Parameter Type Description
RefType BYTE Reference
type
(default
value is
6hex)
FileNumber WORD File Number
RecordNumber WORD Record
Number
RecordLength WORD Record
Length
xEnablePoll BOOL Polling enabled. No need for
xSendRequest to be triggered every
interval. The block sends requests
automatically
tPollInterval TIME Polling interval. Request is sent
continuously in intervals. For example:
every one second
tTimeout TIME Timeout interval for slaves to respond

17.16.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process
is done. It is valid (remains true) as long as the
xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC20 MB_RTU_udtDataFC21 Parameter Type Description
ResponseDataLength UINT Response
data length
SubRequestsResult MB_RTU_arr_w_0_124 Sub
requests
Result

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 66 of 85

17.16.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

17.17 MB_RTU_FC21_V1_xx block description


This function block is used to write file record

17.17.1 Block Call

17.17.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
udtSubRequestsData MB_RTU_arr_w_0_124 Array of words contains Sub requests data.
(the low byte of the first word contains the
request data length)
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block
sends requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

17.17.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and
ready to operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 67 of 85

is done. It is valid (remains true) as long as the


xSendRequest input is true.
xError BOOL Error in Request/ Response data. Response
data are invalid. It is valid (remains true) as
long as the xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC21 MB_RTU_udtDataFC21 Parameter Type Description
RequestDataLength UINT Response
(request)
data length
SubRequestsResults MB_RTU_arr_w_0_124 Sub
requests
Result

17.17.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 68 of 85

17.18 MB_RTU_FC22_V1_xx block description


This function block is used to mask write register.

17.18.1 Block Call

17.18.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
wANDMask WORD AND mask
wORMask WORD OR mask
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block sends
requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 69 of 85

17.18.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and ready to
operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process is done. It
is valid (remains true) as long as the xSendRequest
input is true.
xError BOOL Error in Request/ Response data. Response data are
invalid. It is valid (remains true) as long as the
xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors

17.18.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 70 of 85

17.19 MB_RTU_FC23_V1_xx block description


This function block is used to read / write multiple registers.

17.19.1 Block Call

17.19.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiReadStartingAddress UINT Read Starting Address
iQuantityToRead INT Quantity to read
uiWriteStartingAddress UINT Write starting address
iQuantityToWrite INT Quantity to write
udtWriteRegValues MB_RTU_arr_w_0_124 write registers values
xEnablePoll BOOL Polling enabled. No need for xSendRequest
to be triggered every interval. The block
sends requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 71 of 85

17.19.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and ready to
operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process is done.
It is valid (remains true) as long as the xSendRequest
input is true.
xError BOOL Error in Request/ Response data. Response data are
invalid. It is valid (remains true) as long as the
xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC23 MB_RTU_arr_w_0_124 Values of the written registers

17.19.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)

17.20 MB_RTU_FC24_V1_xx block description


This function block is used to read FIFO queue.

17.20.1 Block Call

17.20.2 Input parameters

Input parameters
Name Type Description
xActivate BOOL block activation / deactivation
xSendRequest BOOL A rising edge sends a request.
uiSlaveAddress UINT Slave address
uiStartAddress UINT FIFO pointer address
xEnablePoll BOOL Polling enabled. No need for xSendRequest

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 72 of 85

to be triggered every interval. The block sends


requests automatically
tPollInterval TIME Polling interval. Request is sent continuously
in intervals. For example: every one second
tTimeout TIME Timeout interval for slaves to respond

17.20.3 Output parameters


Output parameters
Name Type Description
xReady BOOL Function block is successfully initialised and ready to
operate
xBusy BOOL Function block is busy
xDone BOOL Request Send and Response Receive process is done. It
is valid (remains true) as long as the xSendRequest input
is true.
xError BOOL Error in Request/ Response data. Response data are
invalid. It is valid (remains true) as long as the
xSendRequest input is true
wDiagCode WORD Diagnostic Code for errors
udtDataFC24 MB_RTU_udtDataFC24 Parameter Type Description
Bytecount UINT Byte Count
FIFOCount UINT FIFO count
FIFORegValues MB_RTU_arr_w_1_32 FIFO registers
values

17.20.4 Input-Output Parameters


Input-Output Parameters
Name Type Description
udtMBData MB_RTU_MTR_Data Structure of MODBUS parameters
and data. (Not for user)
Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 73 of 85

18 Example
A Measuring device EEM-MA250 is used as a slave.

18.1 Send Requests using MB_RTU_FCdynamic_V1_xx

18.1.1 Needed Blocks


- MB_RTU_FCdynamic_V1_xx
- MB_RTU485_Master_V1_xx

18.1.2 Blocks layout

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 74 of 85

18.1.3 Activation
The Baud rate and data width parameters are set, and the blocks are activated using the input parameter
xActivate.

18.1.4 Putting Request Parameters


After the blocks are activated and the blocks are ready (xReady is true) then the following request
parameters are filled up.

Input parameters of MB_RTU_FCdynamic_V1_00


Name Type Value
uiSlaveAddress UINT UINT#02
iFunctionCode INT 3
uiStartAddress UINT Uint#50526
iQuantityOfData INT 2
arr_wRequestData MB_RTU_arr_w_0_124 Unfilled
tTimeout TIME T#1s

18.1.5 Sending Request using xSendRequest


xSendRequest is set to true.

18.1.5.1 Result

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 75 of 85

Output parameters of MB_RTU_FCdynamic_V1_00


Name Type Value
xReady BOOL True
xBusy BOOL True during execution then false when
done.
xError BOOL False
wDiagCode WORD 16#8000
wAddDiagCode WORD 16#0000
UiNoOfRequests UINT Uint#1
UiNoOfResponses UINT Uint#1

Output parameters of MB_RTU485_Master_V1_01


Name Type Value
xReady BOOL True
xBusy BOOL True during execution then false when done.
xDone BOOL True.
xError BOOL False
wDiagCode WORD 0000 (No error)
arr_wResponseData MB_RTU_arr_w_0_124 arr_wResponseData[0] := 16#0000
arr_wResponseData[1] := 16#12CD

18.1.6 Sending Request using polling


tPollIntervall is set (for example: T#1s, request is sent every one second). The xEnablePoll is set to
true.

18.1.6.1 Result

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 76 of 85

Output parameters of MB_RTU_FCdynamic_V1_00


Name Type Value
xReady BOOL True
xBusy BOOL True during execution then false when
done.
xError BOOL False
wDiagCode WORD 16#8000
wAddDiagCode WORD 16#0000
UiNoOfRequests UINT Uint#10
UiNoOfResponses UINT Uint#10

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 77 of 85

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 78 of 85

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 79 of 85

Output parameters of MB_RTU485_Master_V1_01


Name Type Value
xReady BOOL True
xBusy BOOL True during execution then false when done.
xDone BOOL True for one cycle for each request
xError BOOL False for one cycle for each request
wDiagCode WORD 0000 (No error)
arr_wResponseData MB_RTU_arr_w_0_124 arr_wResponseData[0] := 16#0000
arr_wResponseData[1] := 16#12D8
Each request has its own value

18.2 Send Requests using MB_RTU_FC3_V1_xx

18.2.1 Needed Blocks


- MB_RTU_FC3_V1_xx
- MB_RTU485_Master_V1_xx

18.2.2 Blocks layout

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 80 of 85

18.2.3 Activation
The Baud rate and data width parameters are set, the blocks are activated using the input parameter
xActivate.

18.2.4 Putting Request Parameters


After the blocks are activated and the blocks are ready (xReady is true) then the following request
parameters are filled up.

Input parameters of MB_RTU_FC3_V1_02


Name Type Value
uiSlaveAddress UINT UINT#02
uiStartAddress UINT Uint#51286
uiNoOfRegister UINT UINT#2
tTimeout TIME T#1s

18.2.5 Sending Request using xSendRequest


xSendRequest is set to true.

18.2.5.1 Result

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 81 of 85

Output parameters of MB_RTU_FC3_V1_02


Name Type Value
xReady BOOL True
xBusy BOOL True during execution then false when
done.
xError BOOL False
wDiagCode WORD 16#8000
wAddDiagCode WORD 16#0000
UiNoOfRequests UINT Uint#1
UiNoOfResponses UINT Uint#1

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 82 of 85

Output parameters of MB_RTU485_Master_V1_01


Name Type Value
xReady BOOL True
xBusy BOOL True during execution then false when done.
xDone BOOL True.
xError BOOL False
wDiagCode WORD 0000 (No error)
udtDataFC3 MB_RTU_arr_w_1_125 udtDataFC3 [0] := 16#0000
udtDataFC3 [1] := 16#12D3

18.2.6 Sending Request using polling


tPollIntervall is set (for example: T#1s, request is sent every one second). The xEnablePoll is set to true.

18.2.6.1 Result

Output parameters of MB_RTU_FC3_V1_02


Name Type Value
xReady BOOL True
xBusy BOOL True during execution then false when
done.
xError BOOL False
wDiagCode WORD 16#8000
wAddDiagCode WORD 16#0000

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 83 of 85

UiNoOfRequests UINT Uint#108


UiNoOfResponses UINT Uint#108

Output parameters of MB_RTU485_Master_V1_01


Name Type Value
xReady BOOL True
xBusy BOOL True during execution then false when done.
xDone BOOL True for one cycle for each request
xError BOOL False for one cycle for each request
wDiagCode WORD 0000 (No error)
udtDataFC3 MB_RTU_arr_w_1_125 udtDataFC3 [0] := 16#0000
udtDataFC3 [1] := 16#12D3

18.3 Sending Requests from different blocks


UP to 32 instances from the FC blocks can be connected at the same time for one
MB_RTU485_Master_V1_01 block. To do so, all of the instances should have the same in-out parameter
udtMBData.
Even if the blocks sent their requests simultaneously, the MB_RTU485_Master_V1_01 block will execute
them one after the other.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 84 of 85

19 FAQ

19.1 Communication
l Master and slave are not communicating
¡ Check wiring in Data sheets
¡ Check if the right module is used
¡ For RS485:
n Terminating Resistance is usually needed at end of network
n Terminal points are correctly wired; D(A) with D(A) and D(B) with D(B).
n Baud rate and data width are correctly set
n Example of wiring:

¡ For RS232:
n Terminal points are correctly wired; TX with RX and RX with TX
n Baud rate and data width are correctly set
n Ground should be connected
n Transparent mode, DTR is controlled automatically.
n Wiring example:

19.2 Request and Responses


l Not sure about the contents of the request
¡ Check the MODBUS documentation. Found in http://www.modbus.org/.

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 85 of 85

l Error in Bus system ( C010, FFF)


¡ Check if the process data are connected.
l I am using xEnablePoll, and when I look at the function block, it seems not working, though the
UiNoOfRequests and NoOfReceivedResponses are incrementing
¡ With xEnablePoll, the result (xDone and xError) are set for one cycle so that the next
requests could be processed. A rising trigger or a counter could be used to make it
observable.

Contents

file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019

Das könnte Ihnen auch gefallen