Beruflich Dokumente
Kultur Dokumente
PC
Wor
Function Blocks of
Modbus_V1_xx
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 3 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 4 of 85
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 5 of 85
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
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).
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.
Each byte is sent in an 11-bits frame, where a start bit, a stop bit and a parity bit are added.
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.
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 8 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 11 of 85
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 12 of 85
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 13 of 85
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 14 of 85
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
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 17 of 85
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
For each function code block, Responses are saved in a customised output structure.
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 20 of 85
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
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 23 of 85
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 24 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 27 of 85
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.
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 28 of 85
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 29 of 85
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 30 of 85
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.
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 31 of 85
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.
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 33 of 85
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 34 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 37 of 85
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 38 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 41 of 85
Important: ASCII is less efficient than RTU since each byte needs two characters (two bytes).
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 42 of 85
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.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
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 48 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 49 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 51 of 85
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 52 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 54 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 55 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 57 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 58 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 60 of 85
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 61 of 85
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
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 64 of 85
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 65 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 66 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 67 of 85
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 68 of 85
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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 70 of 85
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
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
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.
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.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
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
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
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.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
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 82 of 85
18.2.6.1 Result
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 83 of 85
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:
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019
Modbus_V1_xx Page 85 of 85
Contents
file:///C:/Users/Public/Documents/PC%20WORX/Libraries/ModBus_V1_07/POE/W... 20/03/2019