Sunteți pe pagina 1din 123

Documentation for

PHOENIX CONTACT function blocks

Function block library

Modbus_V2_04 (RTU)

for the PC Worx control system

from Version 6.10.200 or later

September 23th, 2016/SNI

Documentation for
PHOENIX CONTACT function blocks
PHOENIX CONTACT GmbH & Co. KG
Flachsmarktstraße 8
32825 Blomberg, Germany

Modbus_V2_04_RTU_001.docx Page 1 of 123


Modbus_V2_04

Table of contents
1 Block versions/Change notes ........................................................................................10
2 Release .........................................................................................................................10
3 Function block list ..........................................................................................................11
3.1 Modbus ..................................................................................................................11
3.2 Serial Driver ...........................................................................................................12
4 Introduction ...................................................................................................................13
4.1 General ..................................................................................................................13
4.2 Modbus RTU ..........................................................................................................13
4.3 Block sequence ......................................................................................................14
4.3.1 Master functionality .........................................................................................14
4.3.2 Inline adapter ..................................................................................................15
5 Modbus function blocks .................................................................................................16
5.1 MB_RTU_Master block description ........................................................................16
5.1.1 Block data .......................................................................................................16
5.1.2 Block call .........................................................................................................16
5.1.3 Input parameters .............................................................................................17
5.1.4 Output parameters ..........................................................................................17
5.1.5 Input and output parameters ...........................................................................18
5.1.6 Diagnostics .....................................................................................................18
5.2 Supported Modbus function codes .........................................................................19
5.3 MB_RTU_FC1 block description ............................................................................20
5.3.1 Block data .......................................................................................................20
5.3.2 Block call .........................................................................................................20
5.3.3 Input parameters .............................................................................................21
5.3.4 Output parameters ..........................................................................................21
5.3.5 Input and output parameters ...........................................................................22
5.3.6 Diagnostics .....................................................................................................22
5.4 MB_RTU_FC2 block description ............................................................................23
5.4.1 Block data .......................................................................................................23
5.4.2 Block call .........................................................................................................23
5.4.3 Input parameters .............................................................................................24
5.4.4 Output parameters ..........................................................................................24
5.4.5 Input and output parameters ...........................................................................25
5.4.6 Diagnostics .....................................................................................................25
5.5 MB_RTU_FC3 block description ............................................................................26

Modbus_V2_04_RTU_001.docx Page 2 of 123


Modbus_V2_04

5.5.1 Block data .......................................................................................................26


5.5.2 Block call .........................................................................................................26
5.5.3 Input parameters .............................................................................................27
5.5.4 Output parameters ..........................................................................................27
5.5.5 Input and output parameters ...........................................................................28
5.5.6 Diagnostics .....................................................................................................28
5.6 MB_RTU_FC4 block description ............................................................................29
5.6.1 Block data .......................................................................................................29
5.6.2 Block call .........................................................................................................29
5.6.3 Input parameters .............................................................................................30
5.6.4 Output parameters ..........................................................................................30
5.6.5 Input and output parameters ...........................................................................31
5.6.6 Diagnostics .....................................................................................................31
5.7 MB_RTU_FC5 block description ............................................................................32
5.7.1 Block data .......................................................................................................32
5.7.2 Block call .........................................................................................................32
5.7.3 Input parameters .............................................................................................33
5.7.4 Output parameters ..........................................................................................33
5.7.5 Input and output parameters ...........................................................................34
5.7.6 Diagnostics .....................................................................................................34
5.8 MB_RTU_FC6 block description ............................................................................35
5.8.1 Block data .......................................................................................................35
5.8.2 Block call .........................................................................................................35
5.8.3 Input parameters .............................................................................................36
5.8.4 Output parameters ..........................................................................................36
5.8.5 Input and output parameters ...........................................................................37
5.8.6 Diagnostics .....................................................................................................37
5.9 MB_RTU_FC15 block description ..........................................................................38
5.9.1 Block data .......................................................................................................38
5.9.2 Block call .........................................................................................................38
5.9.3 Input parameters .............................................................................................39
5.9.4 Output parameters ..........................................................................................39
5.9.5 Input and output parameters ...........................................................................40
5.9.6 Diagnostics .....................................................................................................40
5.10 MB_RTU_FC16 block description ..........................................................................41
5.10.1 Block data .......................................................................................................41

Modbus_V2_04_RTU_001.docx Page 3 of 123


Modbus_V2_04

5.10.2 Block call .........................................................................................................41


5.10.3 Input parameters .............................................................................................42
5.10.4 Output parameters ..........................................................................................42
5.10.5 Input and output parameters ...........................................................................43
5.10.6 Diagnostics .....................................................................................................43
5.11 MB_RTU_FC23 block description ..........................................................................44
5.11.1 Block data .......................................................................................................44
5.11.2 Block call .........................................................................................................44
5.11.3 Input parameters .............................................................................................45
5.11.4 Output parameters ..........................................................................................45
5.11.5 Input and output parameters ...........................................................................46
5.11.6 Diagnostics .....................................................................................................46
5.12 MB_RTU_FCx block description ............................................................................47
5.12.1 Block data .......................................................................................................47
5.12.2 Block call .........................................................................................................47
5.12.3 Input parameters .............................................................................................48
5.12.4 Output parameters ..........................................................................................48
5.12.5 Input and output parameters ...........................................................................49
5.12.6 Diagnostics .....................................................................................................49
5.13 MB_RTU_DiagInfo_DE block description ...............................................................50
5.13.1 Block data .......................................................................................................50
5.13.2 Block call .........................................................................................................50
5.13.3 Output parameters ..........................................................................................51
5.13.4 Input and output parameters ...........................................................................51
5.14 MB_RTU_DiagInfo_EN block description ...............................................................52
5.14.1 Block data .......................................................................................................52
5.14.2 Block call .........................................................................................................52
5.14.3 Output parameters ..........................................................................................53
5.14.4 Input and output parameters ...........................................................................53
5.15 MB_RTU_Slave block description ..........................................................................54
5.15.1 Block data .......................................................................................................54
5.15.2 Block call .........................................................................................................54
5.15.3 Input parameters .............................................................................................55
5.15.4 Output parameters ..........................................................................................55
5.15.5 Input and output parameters ...........................................................................56
5.15.6 Diagnostics .....................................................................................................56

Modbus_V2_04_RTU_001.docx Page 4 of 123


Modbus_V2_04

5.16 Modbus diagnostics................................................................................................57


6 Serial driver function blocks...........................................................................................58
6.1 MB_IL_485P_Master block description ..................................................................58
6.1.1 Block data .......................................................................................................58
6.1.2 Block call .........................................................................................................58
6.1.3 Input parameters .............................................................................................59
6.1.4 Output parameters ..........................................................................................59
6.1.5 Input and output parameters ...........................................................................59
6.2 MB_IL_232P_Master block description ..................................................................60
6.2.1 Block data .......................................................................................................60
6.2.2 Block call .........................................................................................................60
6.2.3 Input parameters .............................................................................................61
6.2.4 Output parameters ..........................................................................................61
6.2.5 Input/output parameters ..................................................................................61
6.3 MB_IL_UNI07_Master block description.................................................................62
6.3.1 Block data .......................................................................................................62
6.3.2 Block call .........................................................................................................62
6.3.3 Input parameters .............................................................................................63
6.3.4 Output parameters ..........................................................................................63
6.3.5 Input and output parameters ...........................................................................63
6.4 MB_IL_UNI15_Master block description.................................................................64
6.4.1 Block data .......................................................................................................64
6.4.2 Block call .........................................................................................................64
6.4.3 Input parameters .............................................................................................65
6.4.4 Output parameters ..........................................................................................65
6.4.5 Input and output parameters ...........................................................................65
6.5 MB_IL_UNI31_Master block description.................................................................66
6.5.1 Block data .......................................................................................................66
6.5.2 Block call .........................................................................................................66
6.5.3 Input parameters .............................................................................................67
6.5.4 Output parameters ..........................................................................................67
6.5.5 Input and output parameters ...........................................................................67
6.6 MB_IL_485E_Master block description ..................................................................68
6.6.1 Block data .......................................................................................................68
6.6.2 Block call .........................................................................................................68
6.6.3 Input parameters .............................................................................................69

Modbus_V2_04_RTU_001.docx Page 5 of 123


Modbus_V2_04

6.6.4 Output parameters ..........................................................................................69


6.6.5 Input and output parameters ...........................................................................70
6.7 MB_IL_485P_Slave block description ....................................................................71
6.7.1 Block data .......................................................................................................71
6.7.2 Block call .........................................................................................................71
6.7.3 Input parameters .............................................................................................72
6.7.4 Output parameters ..........................................................................................72
6.7.5 Input and output parameters ...........................................................................72
6.8 MB_IL_232P_Slave block description ....................................................................73
6.8.1 Block data .......................................................................................................73
6.8.2 Block call .........................................................................................................73
6.8.3 Input parameters .............................................................................................74
6.8.4 Output parameters ..........................................................................................74
6.8.5 Input and output parameters ...........................................................................74
6.9 MB_IL_UNI07_Slave block description...................................................................75
6.9.1 Block data .......................................................................................................75
6.9.2 Block call .........................................................................................................75
6.9.3 Input parameters .............................................................................................76
6.9.4 Output parameters ..........................................................................................76
6.9.5 Input and output parameters ...........................................................................76
6.10 MB_IL_UNI15_Slave block description...................................................................77
6.10.1 Block data .......................................................................................................77
6.10.2 Block call .........................................................................................................77
6.10.3 Input parameters .............................................................................................78
6.10.4 Output parameters ..........................................................................................78
6.10.5 Input and output parameters ...........................................................................78
6.11 MB_IL_UNI31_Slave block description...................................................................79
6.11.1 Block data .......................................................................................................79
6.11.2 Block call .........................................................................................................79
6.11.3 Input parameters .............................................................................................80
6.11.4 Output parameters ..........................................................................................80
6.11.5 Input and output parameters ...........................................................................80
6.12 MB_IL_485E_Slave block description ....................................................................81
6.12.1 Block data .......................................................................................................81
6.12.2 Block call .........................................................................................................81
6.12.3 Input parameters .............................................................................................82

Modbus_V2_04_RTU_001.docx Page 6 of 123


Modbus_V2_04

6.12.4 Output parameters ..........................................................................................82


6.12.5 Input and output parameters ...........................................................................83
6.13 MB_Serial_In block description ..............................................................................84
6.13.1 Block data .......................................................................................................84
6.13.2 Block call .........................................................................................................84
6.13.3 Output parameters ..........................................................................................85
6.13.4 Input and output parameters ...........................................................................85
6.14 MB_Serial_Out block description............................................................................86
6.14.1 Block data .......................................................................................................86
6.14.2 Block call .........................................................................................................86
6.14.3 Input parameters .............................................................................................87
6.14.4 Input and output parameters ...........................................................................87
6.15 MB_AXL_RS_UNI_REC block description .............................................................88
6.15.1 Block data .......................................................................................................88
6.15.2 Block call .........................................................................................................88
6.15.3 Input parameters .............................................................................................89
6.15.4 Output parameters ..........................................................................................89
6.15.5 Input and output parameters ...........................................................................89
6.15.6 Diagnostics .....................................................................................................90
6.16 MB_AXL_RS_UNI_SND block description .............................................................91
6.16.1 Block data .......................................................................................................91
6.16.2 Block call .........................................................................................................91
6.16.3 Input parameters .............................................................................................92
6.16.4 Output parameters ..........................................................................................92
6.16.5 Input and output parameters ...........................................................................92
6.16.6 Diagnostics .....................................................................................................93
6.17 MB_IL_RS485P block description ..........................................................................94
6.17.1 Block data .......................................................................................................94
6.17.2 Block call .........................................................................................................94
6.17.3 Input parameters .............................................................................................95
6.17.4 Output parameters ..........................................................................................96
6.17.5 Input and output parameters ...........................................................................96
6.17.6 Diagnostics .....................................................................................................97
6.18 MB_IL_RS485P_TRNSP block description ............................................................98
6.18.1 Block data .......................................................................................................98
6.18.2 Block call .........................................................................................................98

Modbus_V2_04_RTU_001.docx Page 7 of 123


Modbus_V2_04

6.18.3 Input parameters .............................................................................................99


6.18.4 Output parameters ..........................................................................................99
6.19 MB_IL_RS232P block description ........................................................................100
6.19.1 Block data .....................................................................................................100
6.19.2 Block call .......................................................................................................100
6.19.3 Input parameters ...........................................................................................101
6.19.4 Output parameters ........................................................................................102
6.19.5 Input and output parameters .........................................................................102
6.19.6 Diagnostics ...................................................................................................103
6.20 MB_IL_RS232P_TRNSP block description ..........................................................104
6.20.1 Block data .....................................................................................................104
6.20.2 Block call .......................................................................................................104
6.20.3 Input parameters ...........................................................................................105
6.20.4 Output parameters ........................................................................................105
6.21 MB_IL_RSUNIxx block description .......................................................................106
6.21.1 Block data .....................................................................................................106
6.21.2 Block call .......................................................................................................106
6.21.3 Input parameters ...........................................................................................107
6.21.4 Output parameters ........................................................................................108
6.21.5 Input and output parameters .........................................................................108
6.21.6 Diagnostics ...................................................................................................109
6.22 MB_IL_RSUNI_TRNSP block description ............................................................110
6.22.1 Block data .....................................................................................................110
6.22.2 Block call .......................................................................................................110
6.22.3 Input parameters ...........................................................................................111
6.22.4 Output parameters ........................................................................................112
7 Startup instructions......................................................................................................113
7.1 Master or slave with integrated serial driver .........................................................113
7.2 Serial driver Axioline.............................................................................................114
7.3 Master function.....................................................................................................116
7.4 Sending requests cyclically ..................................................................................117
7.5 Adapter serial driver .............................................................................................118
7.6 Slave functionality ................................................................................................119
7.7 Multiple Inline slaves in the same network ............................................................120
8 Appendix A (Sending requests with MB_RTU_FCx_V2_01) ........................................121
9 FAQ.............................................................................................................................123

Modbus_V2_04_RTU_001.docx Page 8 of 123


Modbus_V2_04

9.1 Interval between requests ....................................................................................123


9.2 Cycle time and PROFINET update time for inputs and outputs ............................123
9.3 xActive is False ....................................................................................................123

Modbus_V2_04_RTU_001.docx Page 9 of 123


Modbus_V2_04

1 Block versions/Change notes


Version Description
1.00 Initial Version
1.07  Support of modules with serial interfaces: IB IL RS232, RS485, and RS UNI
 Support of the ASCII mode
2.00  MB_RTU_Master_V2_00: New concept: Serial function blocks are separated from the
master function block. Master FB works together with all supported serial interfaces
 MB_AXL_RS_UNI_xx: Support of the module AXL F RS UNI 1H
 MB_RTU_xx: Unlimited number of FC FBs depending on the master block
 MB_AXCIIxx: Cancel Support of the ASCII mode
2.01  MB_Serial_In(Out)_xx: More stability for Inline modules
 MB_AXL_RS_UNI_xx: Update diagnostic codes of Axioline serial driver
2.02  MB_IL_xx_Master_xx: Added new RTU Master FB with integrated IL-driver
 MB_IL_xx_Slave_xx: Added new RTU Slave FB with integrated IL-driver
 MB_ILRSxx: Added separate serial Driver for Inline modules
 MB_RTU_FCxx: Arrayparameter defined as In/Out-Variables
2.03  Support of Slave adresses from 0 to 255, previously 0 to 247
2.04  Support of Serial Functionmodule IB IL RS 485-ECO: MB_IL_485E_Master,
MB_IL_485E_Slave
 Improvement of serial communication via Modbus-Master
TOP

2 Release
The direct specification of the data width on the input parameter wDatawidth of the
MB_IL_RSUNI_TRNSP_V1_00 function block is only possible for the IB IL RS UNI module
FW later 1.00.
TOP

Modbus_V2_04_RTU_001.docx Page 10 of 123


Modbus_V2_04

3 Function block list


The following table lists the blocks that configure the controller as Modbus master or Modbus
slave including serial interfaces.

3.1 Modbus

Block Description Version Article


MB_RTU_Master The function block enables 2.04 ---
communication as master with
Modbus RTU devices.
MB_RTU_FCn The library contains function 2.01/ ---
blocks for function codes 1, 2, 3, 2.02
4, 5, 6, 15, 16, and 23.
MB_RTU_FCx The function block can be 2.01 ---
parameterized for all possible
function codes.
MB_RTU_DiagInfo_DE This optional function block 2.01 ---
displays diagnostic messages of
the Modbus communication as
clear text in German.
MB_RTU_DiagInfo_EN This optional function block 2.01 ---
displays diagnostic messages of
the Modbus communication as
clear text in English.
MB_RTU_Slave The function block enables 2.01 ---
communication as slave with a
Modbus network.

TOP

Modbus_V2_04_RTU_001.docx Page 11 of 123


Modbus_V2_04

3.2 Serial Driver

Block Description Version Article


MB_IL_485P_Master This function block is used to 1.02 IB IL RS 485/422-
implement a Modbus Master PRO
including the respective serial
MB_IL_232P_Master 1.02 IB IL RS 232-PRO
interface
MB_IL_UNI07_Master 1.02 IB IL RS UNI-PAC
MB_IL_UNI15_Master 1.02 IB IL RS UNI-PAC
MB_IL_UNI31_Master 1.02 IB IL RS UNI-PAC
MB_IL_485E_Master 1.00 IB IL RS 485-ECO
MB_IL_485P_Slave This function block is used to 1.00 IB IL RS 485/422-
implement a Modbus Slave PRO
including the respective serial
MB_IL_232P_Slave interface 1.00 IB IL RS 232-PRO
MB_IL_UNI07_Slave 1.00 IB IL RS UNI-PAC
MB_IL_UNI15_Slave 1.00 IB IL RS UNI-PAC
MB_IL_UNI31_Slave 1.00 IB IL RS UNI-PAC
MB_IL_485E_Slave 1.00 IB IL RS 485-ECO
MB_Serial_In The function block adapts 2.10 Modules supported
existing blocks for serial by Library ComSerial
MB_Serial_Out communication with Inline 2.01
modules.
MB_AXL_RS_UNI_RCV The function block is used to 1.01 AXL F RS UNI 1H
receive data via the serial
MB_AXL_RS_UNI_SND interface with Axioline modules. 1.01 AXL F RS UNI 1H

MB_ILRS485P The function block is used to 1.00 IB IL RS 485/422-


receive data via the serial PRO
interface with Inline modules.
MB_ILRS485P_TRNSP (Library ComSerial_V1_17) IB IL RS 485/422-
PRO
MB_ILRS232P IB IL RS 232-PRO
MB_ILRS232P_TRNSP IB IL RS 232-PRO
MB_ILRSUNIxx IB IL RS UNI-PAC
MB_ILRSUNI_TRNSP IB IL RS UNI-PAC

TOP

Modbus_V2_04_RTU_001.docx Page 12 of 123


Modbus_V2_04

4 Introduction
4.1 General
Modbus is a communication protocol used for serial communication. It is a master/slave
protocol. Only one master is connected to the bus at a time. In addition, one or more slaves
(247, maximum) are connected to the same serial bus.
Modbus communication is always initiated by the master. The master sends a request, then
the slave specified in the request responds. It is possible to send a request to all slaves
(broadcast).
The slaves will never transmit data without receiving a request from the master. In addition,
the slaves do not communicate with each other. The master initiates only one Modbus
transaction at a time.
There are four data types stored in a Modbus device memory: discrete inputs (bits), coils
(bits), holding registers (16-bit registers), and input registers (16-bit registers).

4.2 Modbus RTU


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

Figure 1: Telegram frame Modbus RTU

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

Figure 2: Byte format in the Modbus RTU


TOP

Modbus_V2_04_RTU_001.docx Page 13 of 123


Modbus_V2_04

4.3 Block sequence

4.3.1 Master functionality


The serial driver is divided into two blocks in this library to achieve a fast communication
speed. The blocks of the serial driver as well as the Modbus master are connected with each
other by the same structure (here: udtSerialIF). The master communicates via a further
structure (here: udtMbData) with the individual function code blocks.
Sending and receiving blocks always have to be instantiated in the program. The receiving
block has to be invoked first and then the sending block.

TOP

Modbus_V2_04_RTU_001.docx Page 14 of 123


Modbus_V2_04

4.3.2 Inline adapter


To use serial interface modules of the Inline family for Modbus communication, the
blocks of the ComSerial library can be used together with the blocks
MB_Serial_In_V2_10 and MB_Serial_Out_V2_00. The blocks also control the serial
driver via the structure udtSerialIF.

TOP

Modbus_V2_04_RTU_001.docx Page 15 of 123


Modbus_V2_04

5 Modbus function blocks


5.1 MB_RTU_Master block description

This block controls the requests of the FC blocks and sends the Modbus request to the
Modbus network via the connected serial interface. The response is analyzed in this block
and forwarded to the requesting block.
Diagnostic information on the Modbus requests is displayed at the respective FC block.

5.1.1 Block data

Block name: MB_RTU_Master


Block type: Function block
Version: 2.04
Author: SNI
Controller types: ILCxxx, AXCxxx

5.1.2 Block call

Modbus_V2_04_RTU_001.docx Page 16 of 123


Modbus_V2_04

5.1.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xReset BOOL The input resets the block. All connected FC blocks are
reset as well.
tTimeout TIME The block monitors the communication to the serial driver
block. The default value for times less than 10 ms is set to
1 second. The input is copied by xActivate or xReset if
there is a rising edge.
xAuto_CRC BOOL True The CRC is calculated by the module (only
AXL F RS UNI).
False The CRC is calculated in the block.

Important: The function of the Auto CRC calculation from the AXL F RS UNI module with the
HW/FW 01/1.00 can be used up to a data length of 17 bytes in the Modbus protocol!
(Section: Startup instructions 'Serial driver Axioline')

5.1.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xError BOOL This parameter indicates an error. The error message can
be deleted by deactivating the block.
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.
uiRequestsCounter UINT Shows the number of requests transmitted.
uiResponsesCounter UINT Shows the number of responses received.

Modbus_V2_04_RTU_001.docx Page 17 of 123


Modbus_V2_04

5.1.5 Input and output parameters

Input and output parameters

Name Type Description


udtSerialIF MB2_AXL_RSUNI2_UDT_IF The block communicates via this structure with the
Modbus driver block.
udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.1.6 Diagnostics

wDiagCode Meaning
0000hex Block is not activated.
8000hex Block is active and operating without errors.

The diagnostics shown on the block are described in section Modbus diagnostics.
The block shows also the diagnostics of the serial driver blocks.
TOP

Modbus_V2_04_RTU_001.docx Page 18 of 123


Modbus_V2_04

5.2 Supported Modbus function codes

Function code Description


01 Read Coils This function block reads digital outputs.
02 Read Discrete Inputs This function block reads digital inputs.
03 Read Holding Registers This function block reads holding registers.
04 Read Input Registers This function block reads input registers.
05 Write Single Coil This function block writes a bit.
06 Write Single Register This function block writes a register.
15 Write Multiple Coils This function block writes multiple bits.
16 Write Multiple Registers This function block writes multiple registers.
23 Read/Write Multiple Registers This function block reads/writes multiple registers.

Using this block, the request is configured and sent. Input parameters are specified for each
function code.
All FC blocks that communicate with the master (MB_RTU_Master_V2_00) also have to be
connected via the same parameter udtMBData.

It is possible to use more than one instance in the same program.

Note regarding FC function blocks:


The xDone and xError outputs indicate completion of send-receive process. Output 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
TOP

Modbus_V2_04_RTU_001.docx Page 19 of 123


Modbus_V2_04

5.3 MB_RTU_FC1 block description

This function block reads digital inputs from a Modbus slave.

5.3.1 Block data

Block name: MB_RTU_FC1


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.3.2 Block call

Modbus_V2_04_RTU_001.docx Page 20 of 123


Modbus_V2_04

5.3.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated with a
rising edge.
A falling edge deletes current Modbus errors and resets
the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A falling edge
deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is cyclical in
the time interval of the specified value.
uiSlaveAddress INT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the bit to be read
on the slave.
iDataCount INT The input specifies the number of bits to be read on the
slave (1…2000).

5.3.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 21 of 123


Modbus_V2_04

5.3.5 Input and output parameters

Input and output parameters

Name Type Description


arrReadData arrModbus2_X_1_2000 The parameter contains the requested Modbus data.
udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.3.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 22 of 123


Modbus_V2_04

5.4 MB_RTU_FC2 block description

This function block reads digital inputs from a Modbus slave.

5.4.1 Block data

Block name: MB_RTU_FC2


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.4.2 Block call

Modbus_V2_04_RTU_001.docx Page 23 of 123


Modbus_V2_04

5.4.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated with a
rising edge.
A falling edge deletes current Modbus errors and resets
the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A falling edge
deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is cyclical in
the time interval of the specified value.
uiSlaveAddress INT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the bit to be read
on the slave.
iDataCount INT The input specifies the number of bits to be read on the
slave (1…2000).

5.4.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 24 of 123


Modbus_V2_04

5.4.5 Input and output parameters

Input and output parameters

Name Type Description


arrReadData arrModbus2_X_1_2000 The parameter contains the requested Modbus data.
udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.4.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 25 of 123


Modbus_V2_04

5.5 MB_RTU_FC3 block description

This function block reads digital registers from a Modbus slave.

5.5.1 Block data

Block name: MB_RTU_FC3


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.5.2 Block call

Modbus_V2_04_RTU_001.docx Page 26 of 123


Modbus_V2_04

5.5.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated with a
rising edge.
A falling edge deletes current Modbus errors and resets
the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A falling edge
deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is cyclical in
the time interval of the specified value.
uiSlaveAddress INT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the register to be
read on the slave.
iDataCount INT The input specifies the number of registers to be read on
the slave (1…125).

5.5.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 27 of 123


Modbus_V2_04

5.5.5 Input and output parameters

Input and output parameters

Name Type Description


arrReadData arrModbus2_W_1_125 The parameter contains the requested Modbus data.
udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.5.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 28 of 123


Modbus_V2_04

5.6 MB_RTU_FC4 block description

This function block reads digital registers from a Modbus slave.

5.6.1 Block data

Block name: MB_RTU_FC4


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.6.2 Block call

Modbus_V2_04_RTU_001.docx Page 29 of 123


Modbus_V2_04

5.6.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated with a
rising edge.
A falling edge deletes current Modbus errors and resets
the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A falling edge
deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is cyclical in
the time interval of the specified value.
uiSlaveAddress INT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the register to be
read on the slave.
iDataCount INT The input specifies the number of registers to be read on
the slave (1…125).

5.6.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 30 of 123


Modbus_V2_04

5.6.5 Input and output parameters

Input and output parameters

Name Type Description


arrReadData arrModbus2_W_1_125 The parameter contains the requested Modbus data.
udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.6.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 31 of 123


Modbus_V2_04

5.7 MB_RTU_FC5 block description

This function block writes a bit in the memory of a Modbus slave.

5.7.1 Block data

Block name: MB_RTU_FC5


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.7.2 Block call

Modbus_V2_04_RTU_001.docx Page 32 of 123


Modbus_V2_04

5.7.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated with a
rising edge.
A falling edge deletes current Modbus errors and resets
the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A falling edge
deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is cyclical in
the time interval of the specified value.
uiSlaveAddress INT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the bit to be written
on the slave.
xValue BOOL The status of the input is written in the memory to be
written.

5.7.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 33 of 123


Modbus_V2_04

5.7.5 Input and output parameters

Input and output parameters

Name Type Description


udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.7.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 34 of 123


Modbus_V2_04

5.8 MB_RTU_FC6 block description

This function block writes a register into the memory of a Modbus slave.

5.8.1 Block data

Block name: MB_RTU_FC6


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.8.2 Block call

Modbus_V2_04_RTU_001.docx Page 35 of 123


Modbus_V2_04

5.8.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated with a
rising edge.
A falling edge deletes current Modbus errors and resets
the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A falling edge
deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is cyclical in
the time interval of the specified value.
uiSlaveAddress INT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the registers on the
slave.
wValue BOOL The value of the input is written into the memory to be
written.

5.8.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 36 of 123


Modbus_V2_04

5.8.5 Input and output parameters

Input and output parameters

Name Type Description


udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.8.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 37 of 123


Modbus_V2_04

5.9 MB_RTU_FC15 block description

This function block writes multiple bits into the memory of a Modbus slave.

5.9.1 Block data

Block name: MB_RTU_FC15


Block type: Function block
Version: 2.02
Author: SNI
Controller types: ILCxxx, AXCxxx

5.9.2 Block call

Modbus_V2_04_RTU_001.docx Page 38 of 123


Modbus_V2_04

5.9.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated
with a rising edge.
A falling edge deletes current Modbus errors and
resets the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A
falling edge deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is
cyclical in the time interval of the specified value.
uiSlaveAddress UINT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the bits
to be written on the slave.
iDataCount INT The input specifies the number of the bits to be
written on the slave (1..1968).
arrBitValues arrModbus2_X_1_1968 The array of 1968 bits contains the desired
values of the addressed bits.

5.9.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 39 of 123


Modbus_V2_04

5.9.5 Input and output parameters

Input and output parameters

Name Type Description


udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.9.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 40 of 123


Modbus_V2_04

5.10 MB_RTU_FC16 block description

This function block writes multiple registers into the memory of a Modbus slave.

5.10.1 Block data

Block name: MB_RTU_FC16


Block type: Function block
Version: 2.02
Author: SNI
Controller types: ILCxxx, AXCxxx

5.10.2 Block call

Modbus_V2_04_RTU_001.docx Page 41 of 123


Modbus_V2_04

5.10.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated
with a rising edge.
A falling edge deletes current Modbus errors and
resets the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A
falling edge deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is
cyclical in the time interval of the specified value.
uiSlaveAddress UINT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the bits
to be written on the slave.
iDataCount INT The input specifies the number of registers to be
written on the slave (1..123).
arrRegisterValues arrModbus2_W_1_123 The array of 123 words contains the desired
values of the addressed register.

5.10.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 42 of 123


Modbus_V2_04

5.10.5 Input and output parameters

Input and output parameters

Name Type Description


udtMbData udtModbus2_Data The block communicates via this structure with the
FC blocks.

5.10.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 43 of 123


Modbus_V2_04

5.11 MB_RTU_FC23 block description

This function block writes or reads multiple bits in or from the memory of a Modbus slave.

5.11.1 Block data

Block name: MB_RTU_FC23


Block typeo: Function block
Version: 2.02
Author: SNI
Controller types: ILCxxx, AXCxxx

5.11.2 Block call

Modbus_V2_04_RTU_001.docx Page 44 of 123


Modbus_V2_04

5.11.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Block activation
False Block deactivation.
xSendRequest BOOL A send request to the master block is activated with a
rising edge.
A falling edge deletes current Modbus errors and
resets the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A falling
edge deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is
cyclical in the time interval of the specified value.
uiSlaveAddress UINT The input specifies the address of the slave to be
communicated with (1…255).
uiStartAddressRead UINT The input specifies the start address of the data to be
read on the slave.
iDataCountRead INT The input specifies the amount of data to be read on
the slave (1..125).
uiStartAddressWrite UINT The input specifies the start address of the data to be
written on the slave.
iDataCountWrite INT The input specifies the amount of the data to be
written on the slave (1..121).
arrRegisterValues arrModbus2_W_1_123 The input contains the data to be written.

5.11.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully received.
xError BOOL This parameter indicates an error. Response data are invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 45 of 123


Modbus_V2_04

5.11.5 Input and output parameters

Input and output parameters

Name Type Description


arrReadData arrModbus2_W_1_125 The parameter contains the requested Modbus data.
udtMbData udtModbus2_Data The block communicates via this structure with the FC blocks.

5.11.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 46 of 123


Modbus_V2_04

5.12 MB_RTU_FCx block description

Using this block, the request is configured and sent. Details of requests vary depending on
the required function code.
The block should have the same parameter udtMBData of the MB_RTU485_Master_V1_xx
block.
The supported function codes are FC 1, 2, 3, 4, 5, 6, 15, 16, and 23.
It is possible to have more than one instance in the same program.
Further information on the configuration of the request parameter can be found in
Appendix A (Sending requests with MB_RTU_FCx_V2_00).

5.12.1 Block data

Block name: MB_RTU_FCx


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.12.2 Block call

TOP

Modbus_V2_04_RTU_001.docx Page 47 of 123


Modbus_V2_04

5.12.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xSendRequest BOOL A send request to the master block is activated
with a rising edge.
A falling edge deletes current Modbus errors and
resets the block outputs.
xEnablePoll BOOL Cyclical polling is started with a rising edge. A
falling edge deactivates the polling.
tPollIntervall TIME If xEnablePoll is activated, then transmission is
cyclical in the time interval of the specified value.
iFunctionCode INT The input specifies the selected function code.
uiSlaveAddress UINT The input specifies the address of the slave to
be communicated with (1…255).
uiStartAddress UINT The input specifies the start address of the data
to be read/written on the slave.
iDataCount INT The input specifies the amount of data to be
read/written on the slave.
arrRegisterValues arrModbus2_W_1_125 The input contains the data to be written.

5.12.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False Block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xDone BOOL Request is sent and response from slave is successfully
received.
xError BOOL This parameter indicates an error. Response data are
invalid
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 48 of 123


Modbus_V2_04

5.12.5 Input and output parameters

Input and output parameters

Name Type Description


arrReadData arrModbus2_W_1_125 The parameter contains the requested Modbus data.
udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

5.12.6 Diagnostics

The diagnostics shown on the block are described in section Modbus diagnostics.
TOP

Modbus_V2_04_RTU_001.docx Page 49 of 123


Modbus_V2_04

5.13 MB_RTU_DiagInfo_DE block description

If there is an error, this block shows the diagnostics of the master block as a text in German.
The source code of the block can be read and modified. To show the diagnostic messages in
other languages, copy the block and translate the diagnostic text into the desired language.
The text output (strDiagInfo) is limited to 80 characters.

5.13.1 Block data

Block name: MB_RTU_DiagInfo_DE


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.13.2 Block call

Modbus_V2_04_RTU_001.docx Page 50 of 123


Modbus_V2_04

5.13.3 Output parameters

Output parameters

Name Type Description


strDiagInfo STRING If there is an error, the variable shows the description for
the current wDiagCode and wAddDiagCode in German.

5.13.4 Input and output parameters

Input and output parameters

Name Type Description


udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

TOP

Modbus_V2_04_RTU_001.docx Page 51 of 123


Modbus_V2_04

5.14 MB_RTU_DiagInfo_EN block description

If there is an error, this block shows the diagnostics of the master block as a text in English.
The source code of the block can be read and modified. To show the diagnostic messages in
other languages, copy the block and translate the diagnostic text into the desired language.
The text output (strDiagInfo) is limited to 80 characters.

5.14.1 Block data

Block name: MB_RTU_DiagInfo_EN


Block type: Function block
Version: V2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.14.2 Block call

Modbus_V2_04_RTU_001.docx Page 52 of 123


Modbus_V2_04

5.14.3 Output parameters

Output parameters

Name Type Description


strDiagInfo STRING If there is an error, the variable shows the description for
the current wDiagCode and wAddDiagCode in English.

5.14.4 Input and output parameters

Input and output parameters

Name Type Description


udtMbData udtModbus2_Data The block communicates via this structure with the FC
blocks.

TOP

Modbus_V2_04_RTU_001.docx Page 53 of 123


Modbus_V2_04

5.15 MB_RTU_Slave block description

This block configures the controller as the Modbus slave. The slave contains data fields that
can be retrieved in a Modbus network. The function codes 1, 2, 3, 4, 5, 6, 15, and 16 are
supported. A slave can be connected to only one serial interface.

5.15.1 Block data

Block name: MB_RTU_Slave


Block type: Function block
Version: 2.00
Author: SNI
Controller types: ILCxxx, AXCxxx

5.15.2 Block call

Modbus_V2_04_RTU_001.docx Page 54 of 123


Modbus_V2_04

5.15.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.
xReset BOOL The input resets the block.
uiSlaveAddress UINT The input specifies the address of the slave to be communicated
with (1…255).
uiOffset UINT The start address is increased by this value.
If the input uiOffset has the value 2000, then the register with
address 3 in the request will be addressed with the address 2003
(2000 + 3).

5.15.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True The block is busy with the service execution.
xError BOOL This parameter indicates an error. The error message can be
deleted by deactivating the block.
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

Modbus_V2_04_RTU_001.docx Page 55 of 123


Modbus_V2_04

5.15.5 Input and output parameters

Input and output parameters

Name Type Description Function code


udtHoldingRegisters MB_RTU_w_0_1999 Array with 2000 words 3, 6, and 16
representing the holding
registers.
The address range is 0-1999.
udtInputRegisters MB_RTU_w_2000_2999 Array with 1000 words 4
representing the input
registers.
The address range is 2000-
2999.
udtOutputBits MB_RTU_x_3000_3999 Array of 1000 bits 1, 5, and 15
representing the digital
outputs.
The address range is 3000-
3999.
udtInputBits MB_RTU_x_4000_4999 Array of 1000 bits 2
representing digital inputs.
The address range is 4000-
4999.
udtSerialIF MB2_AXL_RSUNI2_UDT_IF The block communicates via this structure with the
Modbus driver block.

5.15.6 Diagnostics

wDiagCode Meaning
0000hex Block is not activated.
8000hex Block is active and operating without errors.

The block shows the diagnostics of the serial driver blocks. (Section: Diagnostics
MB_AXL_RS_UNI_REC and MB_AXL_RS_UNI_SND).
TOP

Modbus_V2_04_RTU_001.docx Page 56 of 123


Modbus_V2_04

5.16 Modbus diagnostics

The diagnostics contains diagnostic codes on the FC blocks of the library. Modbus errors are
indicated at the respective FC block and need to be reset there. Thus the communication in a
Modbus network is not disturbed by an error in a request to a slave. An error at the FC block
is deleted by a reset of the send input or by renewed activation of the block.
Modbus exception codes are sent by the respective slave and contain messages specific for
Modbus.

DiagCode Meaning
0000hex Block is not active
8000hex Block is active
8300hex Block executes a service.
C100hex Error during configuration (displayed on the FC block)
AddDiagCode Meaning
0001hex Slave address is outside the valid range
0002hex Number of the requested data amount invalid (iDataCount)
C110hex Error in the Modbus (displayed on the FC block)
AddDiagCode Meaning
0001hex Timeout on master block
0002hex Checksum (CRC) invalid
0003hex Function code invalid
0004hex Modbus response invalid
C120hex Modbus Exception Code (shown at the FC block)
AddDiagCode Meaning
0001hex Exception Code 1 (Illegal Function)
0002hex Exception Code 2 (Illegal Data Address)
0003hex Exception Code 3 (Illegal Data Value)
0004hex Exception Code 4 (Server Device Failure)
0005hex Exception Code 5 (Acknowledge)
0006hex Exception Code 6 (Server Device Busy)
0008hex Exception Code 8 (Memory Parity Error)
000Ahex Exception Code 10 (Gateway Path Unavailable)
000Bhex Exception Code 11 (Gateway Target Device Failed To Respond)

These diagnostic codes, as well as xError, are reset by a falling edge of xActivate or
xSendRequest on an FC block.

Modbus_V2_04_RTU_001.docx Page 57 of 123


Modbus_V2_04

The block also shows the diagnostics of the master block and thus shows the serial drive
block. These errors need to be reset deactivating the affected blocks. (Section: Diagnostics
MB_AXL_RS_UNI_REC and MB_AXL_RS_UNI_SND).
TOP

6 Serial driver function blocks


6.1 MB_IL_485P_Master block description

This function block is used to implement a Modbus Master for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.1.1 Block data

Block name: MB_IL_485P_Master


Block type: Function block
Version: 1.01
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS 485/RS422-PRO

6.1.2 Block call

Modbus_V2_04_RTU_001.docx Page 58 of 123


Modbus_V2_04

6.1.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Master
diBaudrate DINT MB_IL_RS485P_TRNSP
bDataWidth BYTE MB_IL_RS485P_TRNSP
xRS422 BOOL MB_IL_RS485P_TRNSP
xReset BOOL MB_RTU_Master
tTimeout TIME MB_RTU_Master

6.1.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Master
xBusy BOOL MB_RTU_Master
xReady BOOL MB_IL_RS485P
uiRequestsCounter UINT MB_RTU_Master
uiResponsesCounter UINT MB_RTU_Master
udtAddData MB2_COM_UDT_RS485P_DATA_V1 MB_IL_RS485P
xError BOOL MB_RTU_Master
wDiagCode WORD MB_RTU_Master
wAddDiagCode WORD MB_RTU_Master

6.1.5 Input and output parameters

Input and output parameters

Name Type See description:


udtMBData udtModbus2_Data MB_RTU_Master
arrInputAddress MB2_COM_ARR_B_1_12 MB_IL_RS485P
arrOutputAddress MB2_COM_ARR_B_1_12 MB_IL_RS485P

Modbus_V2_04_RTU_001.docx Page 59 of 123


Modbus_V2_04

6.2 MB_IL_232P_Master block description

This function block is used to implement a Modbus Master for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.2.1 Block data

Block name: MB_IL_232P_Master


Block type: Function block
Version: 1.01
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS232 PRO

6.2.2 Block call

Modbus_V2_04_RTU_001.docx Page 60 of 123


Modbus_V2_04

6.2.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Master
diBaudrate DINT MB_IL_RS232P_TRNSP
bDataWidth BYTE MB_IL_RS232P_TRNSP
xDTR_Control BOOL MB_IL_RS232P_TRNSP
xDTR BOOL MB_IL_RS232P
xCTS_Output BOOL MB_IL_RS232P_TRNSP
xReset BOOL MB_RTU_Master
tTimeout TIME MB_RTU_Master

6.2.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Master
xBusy BOOL MB_RTU_Master
xReady BOOL MB_IL_RS232P
uiRequestsCounter UINT MB_RTU_Master
uiResponsesCounter UINT MB_RTU_Master
udtAddData MB2_COM_UDT_R232P_DATA_V1 MB_IL_RS232P
xError BOOL MB_RTU_Master
wDiagCode WORD MB_RTU_Master
wAddDiagCode WORD MB_RTU_Master

6.2.5 Input/output parameters

Input and output parameters

Name Type See description:


udtMBData udtModbus2_Data MB_RTU_Master
arrInputAddress MB2_COM_ARR_B_1_12 MB_IL_RS232P
arrOutputAddress MB2_COM_ARR_B_1_12 MB_IL_RS232P

Modbus_V2_04_RTU_001.docx Page 61 of 123


Modbus_V2_04

6.3 MB_IL_UNI07_Master block description

This function block is used to implement a Modbus Master for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.3.1 Block data

Block name: MB_IL_UNI07_Master


Block type: Function block
Version: 1.01
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS UNI

6.3.2 Block call

Modbus_V2_04_RTU_001.docx Page 62 of 123


Modbus_V2_04

6.3.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Master
bSelectMode BYTE MB_IL_RSUNI_TRNSP
diBaudrate DINT MB_IL_RSUNI_TRNSP
wDataWidth WORD MB_IL_RSUNI_TRNSP
xDTR_Control BOOL MB_IL_RSUNI_TRNSP
xDTR BOOL MB_IL_RSUNIxx
xReset BOOL MB_RTU_Master
tTimeout TIME MB_RTU_Master

6.3.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Master
xBusy BOOL MB_RTU_Master
xReady BOOL MB_IL_RSUNIxx
uiRequestsCounter UINT MB_RTU_Master
uiResponsesCounter UINT MB_RTU_Master
udtAddData MB2_RSUNI_UDT_DATA_V1 MB_IL_RSUNIxx
xError BOOL MB_RTU_Master
wDiagCode WORD MB_RTU_Master
wAddDiagCode WORD MB_RTU_Master

6.3.5 Input and output parameters

Input and output parameters

Name Type See description:


udtMBData udtModbus2_Data MB_RTU_Master
arrInputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx
arrOutputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx

Modbus_V2_04_RTU_001.docx Page 63 of 123


Modbus_V2_04

6.4 MB_IL_UNI15_Master block description

This function block is used to implement a Modbus Master for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.4.1 Block data

Block name: MB_IL_UNI15_Master


Block type: Function block
Version: 1.01
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS UNI

6.4.2 Block call

Modbus_V2_04_RTU_001.docx Page 64 of 123


Modbus_V2_04

6.4.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Master
bSelectMode BYTE MB_IL_RSUNI_TRNSP
diBaudrate DINT MB_IL_RSUNI_TRNSP
wDataWidth WORD MB_IL_RSUNI_TRNSP
xDTR_Control BOOL MB_IL_RSUNI_TRNSP
xDTR BOOL MB_IL_RSUNIxx
xReset BOOL MB_RTU_Master
tTimeout TIME MB_RTU_Master

6.4.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Master
xBusy BOOL MB_RTU_Master
xReady BOOL MB_IL_RSUNIxx
uiRequestsCounter UINT MB_RTU_Master
uiResponsesCounter UINT MB_RTU_Master
udtAddData MB2_RSUNI_UDT_DATA_V1 MB_IL_RSUNIxx
xError BOOL MB_RTU_Master
wDiagCode WORD MB_RTU_Master
wAddDiagCode WORD MB_RTU_Master

6.4.5 Input and output parameters

Input and output parameters

Name Type See description:


udtMBData udtModbus2_Data MB_RTU_Master
arrInputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx
arrOutputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx

Modbus_V2_04_RTU_001.docx Page 65 of 123


Modbus_V2_04

6.5 MB_IL_UNI31_Master block description

This function block is used to implement a Modbus Master for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.5.1 Block data

Block name: MB_IL_UNI31_Master


Block type: Function block
Version: 1.01
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS UNI

6.5.2 Block call

Modbus_V2_04_RTU_001.docx Page 66 of 123


Modbus_V2_04

6.5.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Master
bSelectMode BYTE MB_IL_RSUNI_TRNSP
diBaudrate DINT MB_IL_RSUNI_TRNSP
wDataWidth WORD MB_IL_RSUNI_TRNSP
xDTR_Control BOOL MB_IL_RSUNI_TRNSP
xDTR BOOL MB_IL_RSUNIxx
xReset BOOL MB_RTU_Master
tTimeout TIME MB_RTU_Master

6.5.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Master
xBusy BOOL MB_RTU_Master
xReady BOOL MB_IL_RSUNIxx
uiRequestsCounter UINT MB_RTU_Master
uiResponsesCounter UINT MB_RTU_Master
udtAddData MB2_RSUNI_UDT_DATA_V1 MB_IL_RSUNIxx
xError BOOL MB_RTU_Master
wDiagCode WORD MB_RTU_Master
wAddDiagCode WORD MB_RTU_Master

6.5.5 Input and output parameters

Input and output parameters

Name Type See description:


udtMBData udtModbus2_Data MB_RTU_Master
arrInputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx
arrOutputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx

Modbus_V2_04_RTU_001.docx Page 67 of 123


Modbus_V2_04

6.6 MB_IL_485E_Master block description

This function block is used to implement a Modbus Master for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.6.1 Block data

Block name: MB_IL_485E_Master


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS 485-ECO

6.6.2 Block call

Modbus_V2_04_RTU_001.docx Page 68 of 123


Modbus_V2_04

6.6.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Master
bSelectMode BYTE Code [hex] Baudrate
0 110
1 300
2 600
3 1200
4 1800
5 2400
6 4800
7 9600
8 15625
9 19200
A 38400
B-F Reserviert
diBaudrate DINT Code [hex] Datenbits Parität Stoppbits
0 7 Gerade 1
1 7 Ungerade 1
2 8 Gerade 1
3 8 Ungerade 1
4 8 Ohne 1
5 7 Ohne 1
6 7 Gerade 2
7 7 Ungerade 2
8 8 Gerade 2
9 8 Ungerade 2
A 8 Ohne 2
B 7 Ohne 2
C 8 Konstant auf 0 1
D 8 Konstant auf 1 1
E 6 Ohne 1
F Reserviert
xReset BOOL MB_RTU_Master
tTimeout TIME MB_RTU_Master

6.6.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Master
xBusy BOOL MB_RTU_Master
xReady BOOL The block is ready to execute
services. When executing services,
this parameter is FALSE.
uiRequestsCounter UINT MB_RTU_Master
uiResponsesCounter UINT MB_RTU_Master
udtAddData MB2_RSUNI_UDT_DATA_V1 Structure with variables for

Modbus_V2_04_RTU_001.docx Page 69 of 123


Modbus_V2_04

Output parameters

Name Type See description:


diagnostics
xError BOOL MB_RTU_Master
wDiagCode WORD MB_RTU_Master
wAddDiagCode WORD MB_RTU_Master

6.6.5 Input and output parameters

Input and output parameters

Name Type See description:


udtMBData udtModbus2_Data MB_RTU_Master
arrInputAddress MB2_RSUNI_ARR_B_1_xx IN process data
arrOutputAddress MB2_RSUNI_ARR_B_1_xx OUT process data

Modbus_V2_04_RTU_001.docx Page 70 of 123


Modbus_V2_04

6.7 MB_IL_485P_Slave block description

This function block is used to implement a Modbus Slave for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.7.1 Block data

Block name: MB_IL_485P_Slave


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS 485/RS422-PRO

6.7.2 Block call

Modbus_V2_04_RTU_001.docx Page 71 of 123


Modbus_V2_04

6.7.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Slave
diBaudrate DINT MB_IL_RS485P_TRNSP
bDataWidth BYTE MB_IL_RS485P_TRNSP
xRS422 BOOL MB_IL_RS485P_TRNSP
uiSlaveAddress UNIT MB_RTU_Slave
uiOffset UINT MB_RTU_Slave
xReset BOOL MB_RTU_Slave

6.7.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Slave
xBusy BOOL MB_RTU_Slave
xReady BOOL MB_IL_RS485P
uiNoOfTransactions UINT MB_RTU_Slave
udtAddData MB2_COM_UDT_RS485P_DATA_V1 MB_IL_RS485P
xError BOOL MB_RTU_Slave
wDiagCode WORD MB_RTU_Slave
wAddDiagCode WORD MB_RTU_Slave

6.7.5 Input and output parameters

Input and output parameters

Name Type See description:


udtHoldingRegisters arrModbus2_w_0_1999 MB_RTU_Slave
udtInputRegisters arrModbus2_w_2000_2999 MB_RTU_Slave
udtOutputBits arrModbus2_x_3000_3999 MB_RTU_Slave
udtInputBits arrModbus2_x_4000_4999 MB_RTU_Slave
arrInputAddress MB2_COM_ARR_B_1_12 MB_IL_RS485P
arrOutputAddress MB2_COM_ARR_B_1_12 MB_IL_RS485P

Modbus_V2_04_RTU_001.docx Page 72 of 123


Modbus_V2_04

6.8 MB_IL_232P_Slave block description

This function block is used to implement a Modbus Slave for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.8.1 Block data

Block name: MB_IL_232P_Slave


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS232 PRO

6.8.2 Block call

Modbus_V2_04_RTU_001.docx Page 73 of 123


Modbus_V2_04

6.8.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Slave
diBaudrate DINT MB_IL_RS232P_TRNSP
bDataWidth BYTE MB_IL_RS232P_TRNSP
xDTR BOOL MB_IL_RS232P
xDTR_Control BOOL MB_IL_RS232P_TRNSP
xCTS_Output BOOL MB_IL_RS232P_TRNSP
xReset BOOL MB_RTU_Slave
uiSlaveAddress UNIT MB_RTU_Slave
uiOffset UINT MB_RTU_Slave

6.8.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Slave
xBusy BOOL MB_RTU_Slave
xReady BOOL MB_IL_RS232P
uiNoOfTransactions UINT MB_RTU_Slave
udtAddData MB2_COM_UDT_R232P_DATA_V1 MB_IL_RS232P
xError BOOL MB_RTU_Slave
wDiagCode WORD MB_RTU_Slave
wAddDiagCode WORD MB_RTU_Slave

6.8.5 Input and output parameters

Input and output parameters

Name Type See description:


udtHoldingRegisters arrModbus2_w_0_1999 MB_RTU_Slave
udtInputRegisters arrModbus2_w_2000_2999 MB_RTU_Slave
udtOutputBits arrModbus2_x_3000_3999 MB_RTU_Slave
udtInputBits arrModbus2_x_4000_4999 MB_RTU_Slave
arrInputAddress MB2_COM_ARR_B_1_12 MB_IL_RS232P
arrOutputAddress MB2_COM_ARR_B_1_12 MB_IL_RS232P

Modbus_V2_04_RTU_001.docx Page 74 of 123


Modbus_V2_04

6.9 MB_IL_UNI07_Slave block description

This function block is used to implement a Modbus Slave for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.9.1 Block data

Block name: MB_IL_UNI07_Slave


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS UNI

6.9.2 Block call

Modbus_V2_04_RTU_001.docx Page 75 of 123


Modbus_V2_04

6.9.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Slave
bSelectMode BYTE MB_IL_RSUNI_TRNSP
diBaudrate DINT MB_IL_RSUNI_TRNSP
wDataWidth WORD MB_IL_RSUNI_TRNSP
xDTR_Control BOOL MB_IL_RSUNI_TRNSP
xDTR BOOL MB_IL_RSUNIxx
uiSlaveAddress UNIT MB_RTU_Slave
uiOffset UINT MB_RTU_Slave
xReset BOOL MB_RTU_Slave

6.9.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Slave
xBusy BOOL MB_RTU_Slave
xReady BOOL MB_IL_RSUNIxx
uiNoOfTransactions UINT MB_RTU_Slave
udtAddData MB2_RSUNI_UDT_DATA_V1 MB_IL_RSUNIxx
xError BOOL MB_RTU_Slave
wDiagCode WORD MB_RTU_Slave
wAddDiagCode WORD MB_RTU_Slave

6.9.5 Input and output parameters

Input and output parameters

Name Type See description:


udtHoldingRegisters arrModbus2_w_0_1999 MB_RTU_Slave
udtInputRegisters arrModbus2_w_2000_2999 MB_RTU_Slave
udtOutputBits arrModbus2_x_3000_3999 MB_RTU_Slave
udtInputBits arrModbus2_x_4000_4999 MB_RTU_Slave
arrInputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx
arrOutputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx

Modbus_V2_04_RTU_001.docx Page 76 of 123


Modbus_V2_04

6.10 MB_IL_UNI15_Slave block description

This function block is used to implement a Modbus Slave for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.10.1 Block data

Block name: MB_IL_UNI15_Slave


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS UNI

6.10.2 Block call

Modbus_V2_04_RTU_001.docx Page 77 of 123


Modbus_V2_04

6.10.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Slave
bSelectMode BYTE MB_IL_RSUNI_TRNSP
diBaudrate DINT MB_IL_RSUNI_TRNSP
wDataWidth WORD MB_IL_RSUNI_TRNSP
xDTR_Control BOOL MB_IL_RSUNI_TRNSP
xDTR BOOL MB_IL_RSUNIxx
uiSlaveAddress UNIT MB_RTU_Slave
uiOffset UINT MB_RTU_Slave
xReset BOOL MB_RTU_Slave

6.10.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Slave
xBusy BOOL MB_RTU_Slave
xReady BOOL MB_IL_RSUNIxx
uiNoOfTransactions UINT MB_RTU_Slave
udtAddData MB2_RSUNI_UDT_DATA_V1 MB_IL_RSUNIxx
xError BOOL MB_RTU_Slave
wDiagCode WORD MB_RTU_Slave
wAddDiagCode WORD MB_RTU_Slave

6.10.5 Input and output parameters

Input and output parameters

Name Type See description:


udtHoldingRegisters arrModbus2_w_0_1999 MB_RTU_Slave
udtInputRegisters arrModbus2_w_2000_2999 MB_RTU_Slave
udtOutputBits arrModbus2_x_3000_3999 MB_RTU_Slave
udtInputBits arrModbus2_x_4000_4999 MB_RTU_Slave
arrInputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx
arrOutputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx

Modbus_V2_04_RTU_001.docx Page 78 of 123


Modbus_V2_04

6.11 MB_IL_UNI31_Slave block description

This function block is used to implement a Modbus Slave for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.11.1 Block data

Block name: MB_IL_UNI31_Slave


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS UNI

6.11.2 Block call

Modbus_V2_04_RTU_001.docx Page 79 of 123


Modbus_V2_04

6.11.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Slave
bSelectMode BYTE MB_IL_RSUNI_TRNSP
diBaudrate DINT MB_IL_RSUNI_TRNSP
wDataWidth WORD MB_IL_RSUNI_TRNSP
xDTR_Control BOOL MB_IL_RSUNI_TRNSP
xDTR BOOL MB_IL_RSUNIxx
uiSlaveAddress UNIT MB_RTU_Slave
uiOffset UINT MB_RTU_Slave
xReset BOOL MB_RTU_Slave

6.11.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Slave
xBusy BOOL MB_RTU_Slave
xReady BOOL MB_IL_RSUNIxx
uiNoOfTransactions UINT MB_RTU_Slave
udtAddData MB2_RSUNI_UDT_DATA_V1 MB_IL_RSUNIxx
xError BOOL MB_RTU_Slave
wDiagCode WORD MB_RTU_Slave
wAddDiagCode WORD MB_RTU_Slave

6.11.5 Input and output parameters

Input and output parameters

Name Type See description:


udtHoldingRegisters arrModbus2_w_0_1999 MB_RTU_Slave
udtInputRegisters arrModbus2_w_2000_2999 MB_RTU_Slave
udtOutputBits arrModbus2_x_3000_3999 MB_RTU_Slave
udtInputBits arrModbus2_x_4000_4999 MB_RTU_Slave
arrInputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx
arrOutputAddress MB2_RSUNI_ARR_B_1_xx MB_IL_RSUNIxx

Modbus_V2_04_RTU_001.docx Page 80 of 123


Modbus_V2_04

6.12 MB_IL_485E_Slave block description

This function block is used to implement a Modbus Slave for the specified module type.
Accordingly the function blocks are connected inside. The required parameters have to be
parameterized on this function block. The associated parameter description refers to the
description of the included function blocks.

6.12.1 Block data

Block name: MB_IL_485E_Slave


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS 485-ECO

6.12.2 Block call

Modbus_V2_04_RTU_001.docx Page 81 of 123


Modbus_V2_04

6.12.3 Input parameters

Input parameters

Name Type See description:


xActivate BOOL MB_RTU_Slave
bBaudrate BYTE Code [hex] Baudrate
0 110
1 300
2 600
3 1200
4 1800
5 2400
6 4800
7 9600
8 15625
9 19200
A 38400
B-F Reserviert
bDataWidth BYTE Code [hex] Datenbits Parität Stoppbits
0 7 Gerade 1
1 7 Ungerade 1
2 8 Gerade 1
3 8 Ungerade 1
4 8 Ohne 1
5 7 Ohne 1
6 7 Gerade 2
7 7 Ungerade 2
8 8 Gerade 2
9 8 Ungerade 2
A 8 Ohne 2
B 7 Ohne 2
C 8 Konstant auf 0 1
D 8 Konstant auf 1 1
E 6 Ohne 1
F Reserviert
uiSlaveAddress UNIT MB_RTU_Slave
uiOffset UINT MB_RTU_Slave
xReset BOOL MB_RTU_Slave

6.12.4 Output parameters

Output parameters

Name Type See description:


xActive BOOL MB_RTU_Slave
xBusy BOOL MB_RTU_Slave
xReady BOOL The block is ready to execute
services. When executing services,
this parameter is FALSE.
uiNoOfTransactions UINT MB_RTU_Slave
udtAddData MB2_RSUNI_UDT_DATA_V1 Structure with variables for

Modbus_V2_04_RTU_001.docx Page 82 of 123


Modbus_V2_04

Output parameters

Name Type See description:


diagnostics
xError BOOL MB_RTU_Slave
wDiagCode WORD MB_RTU_Slave
wAddDiagCode WORD MB_RTU_Slave

6.12.5 Input and output parameters

Input and output parameters

Name Type See description:


udtHoldingRegisters arrModbus2_w_0_1999 MB_RTU_Slave
udtInputRegisters arrModbus2_w_2000_2999 MB_RTU_Slave
udtOutputBits arrModbus2_x_3000_3999 MB_RTU_Slave
udtInputBits arrModbus2_x_4000_4999 MB_RTU_Slave
arrInputAddress MB2_RSUNI_ARR_B_1_xx IN process data
arrOutputAddress MB2_RSUNI_ARR_B_1_xx OUT process data

Modbus_V2_04_RTU_001.docx Page 83 of 123


Modbus_V2_04

6.13 MB_Serial_In block description

This block adapts, in connection with the MB_Serial_Out, serial communication blocks from
the library ComSerial (Sendbuffer more than 257 byte) for Inline modules with the the
Modbus master from this library. Connect the outputs with the inputs of the serial driver
block.

6.13.1 Block data

Block name: MB_Serial_In


Block type: Function block
Version: 2.10
Author: SNI
Controller types: ILCxxx, AXCxxx

6.13.2 Block call

Modbus_V2_04_RTU_001.docx Page 84 of 123


Modbus_V2_04

6.13.3 Output parameters

Output parameters

Name Type Description


xSend BOOL When there is a send command, the block signals a rising
edge.
uiSendLength UINT The block signals the data length to be transmitted.
xReceive BOOL The output is set as soon as data is expected.

6.13.4 Input and output parameters

Input and output parameters

Name Type Description


bSendData BYTE First byte of the data field to be transmitted.
udtSerialIF MB2_AXL_RSUNI2_UDT_IF The block communicates via this structure with the
Modbus driver block.

TOP

Modbus_V2_04_RTU_001.docx Page 85 of 123


Modbus_V2_04

6.14 MB_Serial_Out block description

This block adapts, in connection with the MB_Serial_In_V2_10, serial communication blocks
from the library ComSerial (Sendbuffer more than 257 byte) for Inline modules with the
Modbus master from this library. Connect the inputs with the outputs of the serial driver
block.

6.14.1 Block data

Block name: MB_Serial_Out


Block type: Function block
Version: 2.01
Author: SNI
Controller types: ILCxxx, AXCxxx

6.14.2 Block call

Modbus_V2_04_RTU_001.docx Page 86 of 123


Modbus_V2_04

6.14.3 Input parameters

Input parameters

Name Type Description


xDone BOOL Service executed successfully.
xError BOOL This parameter indicates an error. The error message can
be deleted by deactivating the block.
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.
xRcvBufferNotEmpty BOOL A rising edge signals that new data was received from the
serial interface.

6.14.4 Input and output parameters

Input and output parameters

Name Type Description


bRcvData BYTE First byte of the received data field.
udtSerialIF MB2_AXL_RSUNI2_UDT_IF The block communicates with the Modbus driver block
via this structure.

TOP

Modbus_V2_04_RTU_001.docx Page 87 of 123


Modbus_V2_04

6.15 MB_AXL_RS_UNI_REC block description

This block runs the receiving operations via the AXL F RS UNI 1H module.
The process data width for serial communication is 20 bytes. Of this, 17 bytes are reserved
for the user data.

6.15.1 Block data

Block name: MB_AXL_RS_UNI_REC


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx

6.15.2 Block call

Modbus_V2_04_RTU_001.docx Page 88 of 123


Modbus_V2_04

6.15.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.

6.15.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True: The block is busy with the service execution.
xError BOOL This parameter indicates an error. The error message can
be deleted by deactivating the block.
wDiagCode WORD Diagnostic code
wAddDiagCode WORD Extended diagnostic code

6.15.5 Input and output parameters

Input and output parameters

Name Type Description


udtSerialIF MB2_AXL_RSUNI2_UDT_IF The block communicates with the
Modbus driver block via this
structure.
arrInputDataAXL_RSUNI MB2_AXL_RSUNI2_ARR_B_0_19 Connection of the input process
data of the serial interface.
arrOutputDataAXL_RSUNI MB2_AXL_RSUNI2_ARR_B_0_19 Connection of the output process
data of the serial interface.

Modbus_V2_04_RTU_001.docx Page 89 of 123


Modbus_V2_04

6.15.6 Diagnostics

The following table shows diagnostic codes and their meaning.

wDiagCode Meaning
0000hex Block is not activated.
8000hex Block is active and operating without errors.
C030hex Error when receiving.
wAddDiagCode Meaning
0010hex Timeout when receiving.
0030hex uiRcvLength is larger than the memory available in the receive
buffer
0040hex uiRcvLength <> 0 for end-to-end protocol.
0060hex Communication error when receiving.
C040hex Error in intermediate storage.
wAddDiagCode Meaning
0010hex Timeout in intermediate storage.

TOP

Modbus_V2_04_RTU_001.docx Page 90 of 123


Modbus_V2_04

6.16 MB_AXL_RS_UNI_SND block description

This block runs the sending operations via the AXL F RS UNI 1H module.
The process data width for serial communication is 20 bytes. Of this, 17 bytes are reserved
for the user data.

6.16.1 Block data

Block name: MB_AXL_RS_UNI_SND


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx

6.16.2 Block call

Modbus_V2_04_RTU_001.docx Page 91 of 123


Modbus_V2_04

6.16.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL True Activating the block.
False Deactivating the block.

6.16.4 Output parameters

Output parameters

Name Type Description


xActive BOOL True The block is running without errors.
False The block is not ready for operation.
xBusy BOOL True: The block is busy with the service execution.
xError BOOL This parameter indicates an error. The error message can
be deleted by deactivating the block.
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.

6.16.5 Input and output parameters

Input and output parameters

Name Type Description


udtSerialIF MB2_AXL_RSUNI2_UDT_IF The block communicates with the
Modbus driver block via this
structure.
arrInputDataAXL_RSUNI MB2_AXL_RSUNI2_ARR_B_0_19 Connection of the input process
data of the serial interface.
arrOutputDataAXL_RSUNI MB2_AXL_RSUNI2_ARR_B_0_19 Connection of the output process
data of the serial interface.

Modbus_V2_04_RTU_001.docx Page 92 of 123


Modbus_V2_04

6.16.6 Diagnostics

The following table shows diagnostic codes and their meaning.

wDiagCode Meaning
0000hex Block is not activated.
8000hex Block is active and operating without errors.
C020hex Error when sending
wAddDiagCode Meaning
0020hex Maximum size exceeded when sending.
0060hex Communication error when sending.
C040hex Error in intermediate storage.
wAddDiagCode Meaning
0010hex Timeout in intermediate storage.

TOP

Modbus_V2_04_RTU_001.docx Page 93 of 123


Modbus_V2_04

6.17 MB_IL_RS485P block description

This function block is used to implement the specified module type.

6.17.1 Block data

Block name: MB_ILRS485P


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS 485/RS422-PRO

6.17.2 Block call

Modbus_V2_04_RTU_001.docx Page 94 of 123


Modbus_V2_04

6.17.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL The block is activated.
xReset BOOL Errors are deleted.
The block is reinitialized.
xAutoReset BOOL Errors are deleted automatically.
Errors are displayed at the xError, wDiagCode and
wAddDiagCode output parameters for one cycle
The block is then reinitialized.
udtPara MB2_COM_UDT_ Structure with variables for parameterizing the module.
RS485P_Para_V1
xSend BOOL Trigger parameter.
Data is sent on a positive edge.
The transmission time is monitored by a timeout.
uiSendLength UINT Number of bytes to be sent.
xReceive BOOL Trigger parameter
Data is read on a positive edge.
The receive time is monitored by a timeout.
uiRcvLength UINT Number of bytes to be read.
If the value is 0, all available data is read.
If less data is available than to be read, it waits until these are
made available. The receive time is monitored by a timeout
tTimeout TIME Value for timeout monitoring when sending and receiving.
Timeout when sending: Data could not be transmitted within
the specified time (e.g., buffer full)
Timeout when receiving: Data could not be received within
the specified time (e.g., because connection to IB IL RS
485/RS422-PRO was interrupted)
arrInputAddress MB2_COM_ARR_ IN process data
B_1_12

Modbus_V2_04_RTU_001.docx Page 95 of 123


Modbus_V2_04

6.17.4 Output parameters

Output parameters

Name Type Description


xReady BOOL The block is ready to execute services. When executing
services, this parameter is FALSE.
xDone BOOL Trigger parameter which is set for one cycle following
successful service execution.
When sending: The data was sent successfully.
When receiving: New data was read and are available in the
arrRcvData parameter.
uiRcvBufferLength UINT Number of bytes received.
xRcvBufferNotEmpty BOOL Receive data buffer is not empty. Data can be read.
udtAddData MB2_COM_U Structure with additional status variables. This structure can
DT_RS485P_ be decoded by the IL_RS485P_AddData_V1_0x block.
Data_V1
xError BOOL Errors are indicated.
Is deleted by xReset input, automatic resetting (xAutoReset)
as well deactivating the block with xActivate.
wDiagCode WORD Diagnostic code.
wAddDiagCode WORD Extended diagnostic code.
arrOutputAddress MB2_COM_A OUT process data
RR_B_1_12
diBaudrate DINT Can be set up to 500 kBaud.
Error-free tested operation up to 38.4 kBaud.

6.17.5 Input and output parameters

Input and output parameters

Name Type Description


arrSendData MB2_COM_ARR_B_1_330 Array with the data to be sent.
arrRcvData MB2_COM_ARR_B_1_2048 Array with the received data.

Modbus_V2_04_RTU_001.docx Page 96 of 123


Modbus_V2_04

6.17.6 Diagnostics

DiagCode Meaning
0000hex Block is not activated
8000hex Block is active and operating without errors
C010hex Incorrect terminal type connected
AddDiagCode AddDiagCode
FFFFhex FFFFhex
C020hex Incorrect parameter
AddDiagCode AddDiagCode
0010hex 0010hex
0020hex 0020hex
0030hex 0030hex
0040hex 0040hex
0050hex 0050hex
C030hex AddDiagCode
0010hex 0010hex
0020hex 0020hex
0030hex 0030hex
0040hex 0040hex
Error when Error when receiving
receiving
C040hex AddDiagCode
0010hex 0010hex
0020hex 0020hex
0030hex 0030hex
0040hex 0040hex
3964R protocol 3964R protocol error
error
C050hex AddDiagCode
0010hex 0010hex
0020hex 0020hex
Block is not Block is not activated
activated

Modbus_V2_04_RTU_001.docx Page 97 of 123


Modbus_V2_04

6.18 MB_IL_RS485P_TRNSP block description

This function block is used for parameterization of transparent mode. The parameters are
transferred over the output udtPara to the function block of specified function module.

6.18.1 Block data

Block name: MB_IL_RS485P_TRNSP


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS 485/RS422-PRO

6.18.2 Block call

Modbus_V2_04_RTU_001.docx Page 98 of 123


Modbus_V2_04

6.18.3 Input parameters

Input parameter

Name Type Description


diBaudrate DINT Here, the baud rate can be specified freely up to 500
000. Standard values are 110, 300, 600, 1200, 1800,
2400, 4800, 9600, 19200, 38400
bDataWidth BYTE 0 hex = 7 data bits, even, 1 stop bit
1 hex = 7 data bits, odd, 1 stop bit
2 hex = 8 data bits, even, 1 stop bit
3 hex = 8 data bits, odd, 1 stop bit
4 hex = 8 data bits, none, 1 stop bit
5 hex = 7 data bits, none, 1 stop bit
6 hex = 7 data bits, even, 2 stop bits
7 hex = 7 data bits, odd, 2 stop bits
8 hex = 8 data bits, even, 2 stop bits
9 hex = 8 data bits, odd, 2 stop bits
A hex = 8 data bits, none, 2 stop bits
B hex = 7 data bits, none, 2 stop bits
bErrorPattern BYTE Any character.
xRS422 BOOL True: V.24 (RS422)
False: V.24 (RS485)

6.18.4 Output parameters

Output parameters

Name Type Description


udtPara COM_UDT_RS485P_Para_V1 Parameter structure – input parameter of the
serial interface block

TOP

Modbus_V2_04_RTU_001.docx Page 99 of 123


Modbus_V2_04

6.19 MB_IL_RS232P block description

This function block is used to implement the specified module type.

6.19.1 Block data

Block name: MB_ILRS232P


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS232 PRO

6.19.2 Block call

Modbus_V2_04_RTU_001.docx Page 100 of 123


Modbus_V2_04

6.19.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL Block is activated.
xReset BOOL Errors are deleted. The block is reinitialized.
xAutoReset BOOL Errors are deleted automatically.
Errors are indicated at the xError, wDiagCode,
and wAddDiagCode output parameters for one
cycle. The block is then reinitialized.
udtPara MB2_COM_UDT_RS232_ Structure with variables for parameterizing the
PRO_Para_V1 module.
xDTR BOOL The DTR signal is controlled. Only active if the
corresponding mode is activated (implemented via
the parameterization blocks).
xSend BOOL Trigger parameter. Data is sent on a positive
edge. The transmission time is monitored by a
timeout.
uiSendLength UINT Number of bytes to be sent.
xReceive BOOL Trigger parameter. Data is read on a positive
edge. The receive time is monitored by a timeout.
uiRcvLength UINT Number of bytes to be read. If the value is 0, all
available data is read. If less data is available than
is to be read, the block waits until this data is
available. The receive time is monitored by a
timeout.
tTimeout TIME Value for timeout monitoring when sending and
receiving.
Timeout when sending: The data could not be
sent within the specified time (e.g., buffer full).
Timeout when receiving: The data could not be
received within the specified time (e.g., V.24 (RS-
232) connection interrupted).
arrInputAddress MB2_COM_ARR [1..12] IN process data.
OF BYTE

Modbus_V2_04_RTU_001.docx Page 101 of 123


Modbus_V2_04

6.19.4 Output parameters

Output parameters

Name Type Description


xReady BOOL The block is ready to execute services. W hen
executing services, this parameter is FALSE.
xDone BOOL True: The service is successfully executed.
Meaning
When sending: The data was sent
successfully.
When receiving: New data has been read and is
available in the arrRcvData parameter.
uiRcvBufferLength UINT Number of bytes received.
xRcvBufferNotEmpty BOOL The receive data buffer is not empty, data can be
read.
udtAddData MB2_COM_UDT_RS232 Structure with additional status variables. This
_PRO_Data_V1 structure can be decoded by the
IL_RS232P_AddData_V1_1x block.
xError BOOL Errors are indicated. Deleted by the xReset input,
by an automatic reset (xAutoReset), and by
deactivating the block with xActivate.
wDiagCode WORD Diagnostic code (see Table 5.17.6).
wAddDiagCode WORD Additional diagnostic code (see Table 5.17.6).
diBaudrate DINT Actual baud rate used.
arrOutputAddress MB2_COM_ARR [1..12] OUT process data.
OF BYTE

6.19.5 Input and output parameters

Input and output parameters

Name Type Description


arrSendData COM_ARR [1..xxx] OF BYTE Array with the data to be sent.
arrRcvData COM_ARR [1..xxx] OF BYTE Array with the received data.

Modbus_V2_04_RTU_001.docx Page 102 of 123


Modbus_V2_04

6.19.6 Diagnostics

DiagCode Meaning
0000hex Block not active
8000hex Block is active and operating without errors
C010hex Incorrect terminal type connected
AddDiagCode Meaning
00nnhex Read terminal type
FFFFhex Terminal is not responding
C020hex Incorrect parameter
AddDiagCode Meaning
0010hex Baud rate
0020hex Data width
0030hex Protocol
0040hex Terminal configuration error
C030hex Error when sending
AddDiagCode Meaning
0010hex Timeout when sending
0020hex Maximum size when sending exceeded
0030hex uiSendLength too large
C040hex Error when receiving
AddDiagCode Meaning
0010hex Timeout when receiving
0020hex Maximum size when receiving exceeded
0030hex uiRcvLength too large
0040hex uiRcvLength <> 0 for the end-to-end, 3964R, and dual buffer
protocols
C050hex 3964R protocol error
AddDiagCode Meaning
0010hex Error when sending a 3964R telegram
0020hex Error when receiving a 3964R telegram

Modbus_V2_04_RTU_001.docx Page 103 of 123


Modbus_V2_04

6.20 MB_IL_RS232P_TRNSP block description

This function block is used for parameterization of transparent mode. The parameters are
transferred over the output udtPara to the function block of specified function module.

6.20.1 Block data

Block name: MB_IL_RS232P_TRNSP


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS 232 PRO

6.20.2 Block call

Modbus_V2_04_RTU_001.docx Page 104 of 123


Modbus_V2_04

6.20.3 Input parameters

Input parameters

Name Type Description


diBaudrate DINT Baud rate in the range from 110 baud to 500 kbaud.
bDataW idth BYTE 0 hex = 7 data bits, even, 1 stop bit
1 hex = 7 data bits, odd, 1 stop bit
2 hex = 8 data bits, even, 1 stop bit
3 hex = 8 data bits, odd, 1 stop bit
4 hex = 8 data bits, none, 1 stop bit
5 hex = 7 data bits, none, 1 stop bit
6 hex = 7 data bits, even, 2 stop bits
7 hex = 7 data bits, odd, 2 stop bits
8 hex = 8 data bits, even, 2 stop bits
9 hex = 8 data bits, odd, 2 stop bits
A hex = 8 data bits, none, 2 stop bits
B hex = 7 data bits, none, 2 stop bits
bErrorPattern BYTE Any character.
xDTR_Control BOOL False = The DTR signal is controlled automatically.
True = The DTR signal is controlled by the user.
xCTS_Output BOOL False = CTS signal is not output.
True = CTS signal is output.

6.20.4 Output parameters

Output parameters

Name Type Description


udtPara MB2_COM_UDT_RS232_P Parameter structure - input parameter of the
RO_Para_V1_1x IL_RS232P_xxx_V1_1x block.

TOP

Modbus_V2_04_RTU_001.docx Page 105 of 123


Modbus_V2_04

6.21 MB_IL_RSUNIxx block description

This function block is used to implement the specified module type. This function block is
available for different process data length.

Block name Process data length Data length for sending and reading
MB_ILRSUNI07 7 words 11 byte
MB_ILRSUNI15 15 words 27 byte
MB_ILRSUNI31 31 words 59 byte

6.21.1 Block data

Block name: MB_ILRSUNIxx


Block type: Function block
Version: 1.01
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS UNI

6.21.2 Block call

Modbus_V2_04_RTU_001.docx Page 106 of 123


Modbus_V2_04

6.21.3 Input parameters

Input parameters

Name Type Description


xActivate BOOL Block activation/deactivation
xReset BOOL Error deletion and/or block reinitialization
xAutoReset INT Automatic error deletion.
Errors are indicated at the xError,
wDiagCode, and wAddDiagCode output
parameters for one cycle. The block is
then reinitialized.
udtPara RSUNI_UDT_PARA_V1 Structure with variables for parameterizing
the module
xDTR BOOL The DTR signal is controlled. The signal is
only active if the corresponding mode is
activated. Parameterization blocks are
used for this purpose.
xSend BOOL Trigger parameter. Data is transmitted by
setting a positive edge. The transmission
time is monitored by a timeout.
uiSendLength UINT Number of bytes to be sent
xReceive BOOL Trigger parameter. Data is read by setting
a positive edge. The receive time is
monitored by a timeout.
uiRcvLength UINT Number of bytes to be read. If the value is
0, all data is read. If less data is available
than is to be read, the block waits until
this data is available. The receive time is
monitored by a timeout.
uiMaxRcvBuffer UINT The size of the byte array used under the
bRcvData parameter must be specified
here.
tTimeout TIME Timeout monitoring when sending and
receiving. The input parameter Timeout is
not allowed to be 0.
Timeout when sending: The data could
not be sent within the specified time (e.g.,
transmit buffer full).
Timeout when receiving: The data could
not be received within the specified time
(e.g., module connection interrupted).
arrInputAddress RSUNI_ARR_B_1_xx IN process data

Modbus_V2_04_RTU_001.docx Page 107 of 123


Modbus_V2_04

6.21.4 Output parameters

Output parameters

Name Type Description


xReady BOOL The block is ready to execute services. When
executing services, this parameter is FALSE.
xDone BOOL Once the service has been executed successfully,
the parameter is TRUE.
With regard to sending, this means that data has
been transmitted successfully, with regard to
reading that new data has been read and is
available in the bRcvData parameter.
xError BOOL This parameter indicates an error. The error
message can be deleted via xReset, xAutoReset
or by deactivating the block.
wDiagCode WORD Diagnostic code (see Table 3.6)
wAddDiagCode WORD Extended diagnostic code (see Table 3.6)
diBaudrate DINT Actual baud rate used
uiRcvDataLength UINT Number of bytes to be received
xRcvDataAvailable BOOL If the desired number of characters specified
under uiRcvLength is still available in the
memory, this parameter is TRUE.
udtAddData RSUNI_UDT_DATA_V1 Structure with variables for diagnostics
arrOutputAddress RSUNI_ARR_B_1_xx OUT process data

6.21.5 Input and output parameters

Input and output parameters

Name Type Description


bSendData BYTE Array with data to be transmitted. The first element of a byte
array (e.g., arrTestSend[1]) is transferred here. The number of
characters to be transmitted must be specified with the
uiSendLength parameter.
bRcvData BYTE Array with the received bytes. The first element of a byte array
(e.g., arrTestRcv[1]) is transferred here. The number of
characters to be received must be specified with the
uiRcvLength parameter. When using the end-to-end protocol,
ensure that this parameter is set to “0”. The maximum field size
must be specified with the uiMaxRcvBuffer parameter.

Modbus_V2_04_RTU_001.docx Page 108 of 123


Modbus_V2_04

6.21.6 Diagnostics

wDiagCode Meaning
0000hex Block is not activated
8000hex Block is active and operating without errors
C010hex Incorrect parameters
wAddDiagCode Meaning
0010hex Baud rate
0020hex Data width
0030hex Protocol
0040hex Interface
0050hex Terminal configuration error
0060hex Communication error
C020hex Error when sending
wAddDiagCode Meaning
0010hex Timeout when sending
0020hex Maximum size exceeded when sending
0060hex Communication error when sending
C030hex Error when receiving
wAddDiagCode Meaning
0010hex Timeout when receiving
0030hex uiRcvLength is larger than the field available for receipt.
0040hex uiRcvLength <> 0 for end-to-end protocol
0060hex Communication error when receiving

Modbus_V2_04_RTU_001.docx Page 109 of 123


Modbus_V2_04

6.22 MB_IL_RSUNI_TRNSP block description

This function block is used for parameterization of transparent mode. The parameters are
transferred over the output udtPara to the function block of specified function module.

6.22.1 Block data

Block name: MB_IL_RSUNI_TRNSP


Block type: Function block
Version: 1.00
Author: SNI
Controller types: ILCxxx, AXCxxx
Module type IB IL RS UNI

6.22.2 Block call

Modbus_V2_04_RTU_001.docx Page 110 of 123


Modbus_V2_04

6.22.3 Input parameters

Input parameters

Name Type Description


bSelectMode BYTE Selection of the interface type
Code [hex] Meaning
0 RS-232
1 RS-485
2 RS-422
diBaudrate DINT Here, the baud rate can be specified freely from 110 baud to
262143 baud.
Standard values are 110, 300, 600, 1200, 1800, 2400, 4800,
9600, 19200, 38400, 57600, 115200, 230400, 250000.
wDataWidth WORD Write the code for the data width combination to the low byte. If
you wish to use a data width different from the standard
combination, then write value 0xF to the low byte and your
desired value to the high byte.
The combinations can be found in the data sheet.
Bit 15 ... bit 8 Bit 7 … bit 0
Direct specification Code

Code Data bits Parity Stop bits


[hex]
0 7 Even 1
1 7 Odd 1
2 8 Even 1
3 8 Odd 1
4 8 Without 1
5 7 Without 1
6 7 Even 2
7 7 Odd 2
8 8 Even 2
9 8 Odd 2
A 8 Without 2
B 7 Without 2
C 8 Constantly at 0 1
D 8 Constantly at 1 1
E 6 Without 1
F Direct specification (see data sheet)

Modbus_V2_04_RTU_001.docx Page 111 of 123


Modbus_V2_04

Input parameters

Name Type Description


bErrorPattern BYTE Code [hex] Meaning
24 $
xx Any character
00 If a character is received with
an error, no error pattern is
stored.
FF The invalid character is stored
instead of the error pattern.
xDTR_Control BOOL False = The DTR signal is controlled automatically.
True = The DTR signal is controlled by the user.

6.22.4 Output parameters

Output parameters

Name Type Description


udtPara RSUNI_UDT_PARA_V1 Parameter structure - input parameter of the
IL_RSUNI_xxx_V1_02 block

TOP

Modbus_V2_04_RTU_001.docx Page 112 of 123


Modbus_V2_04

7 Startup instructions
7.1 Master or slave with integrated serial driver

The function blocks MB_IL_x_Master and MB_IL_x_Slave merge the serial drivers and the
Modbus slave or master. This „shells” are used for easy implementation of Inline function
modules as Modbus master or slave.
It is not necessary to integrate the ComSerial library. The serial driver function blocks are
already added to this library

Modbus_V2_04_RTU_001.docx Page 113 of 123


Modbus_V2_04

7.2 Serial driver Axioline


(Refer to documentation: AXL_RSUNI_PD_V1_00_049)
The AXL_RSUNI_PD_V1_00 block provides the user with a convenient option for configuring
a serial connection when using the AXL F RS UNI 1H module. Communication is established
via the process data of the module.
The communication parameters are configured on the device parameter side in the
development environment:

The following communication protocols are used for the Modbus protocol:
Transparent: If the transparent protocol is used, serial data is transmitted through the
terminal in the same format it was received from the serial interface or the bus side. The
sending FIFO (first-in, first-out memory) can store 1023 bytes (1 kbyte) and the receiving
FIFO can store 4096 bytes (4 kbytes). The CRC needs to be calculated here by the master
FB.

Modbus_V2_04_RTU_001.docx Page 114 of 123


Modbus_V2_04

Modbus RTU: The Modbus RTU protocol functions like the transparent protocol. The data
buffer can store only 340 bytes. This protocol supports only the master function in Modbus.
In this case, the CRC is generated automatically and checked automatically when a
message is received. The data is transferred without CRC bytes to the serial driver and is
also received without CRC bytes.
(Refer to data sheet AXL F RS UNI 1H – 2688666)

Release: The function of the Auto CRC calculation from the AXL F RS UNI module with the
HW/FW 01/1.00 can be used up to a data length of 17 bytes in the Modbus protocol.

Modbus_V2_04_RTU_001.docx Page 115 of 123


Modbus_V2_04

7.3 Master function

Execution order: To process the blocks optimally and for fast Modbus communication, the
serial block for receiving has to be placed at the start of the program and the serial block for
sending has to be placed at the end of the program. In between them, the master block is
inserted, followed by the FC block.

Creating structures: The blocks of the serial interface and the Modbus master have to be
connected with each other via the same structure. The Modbus master as well as the FC
blocks are also connected with each other via a structure.(Section 1.4.1)

Instantiation: A master block may by connected to only one serial driver (here: udtSerialIF).
For a second instance, a second serial interface needs to be implemented. Every Modbus
FC can be instantiated multiple times and connected multiple times with the same Modbus
master via udtMbData.
TOP

Modbus_V2_04_RTU_001.docx Page 116 of 123


Modbus_V2_04

7.4 Sending requests cyclically

This figure shows the cyclical sending of a Modbus message. Two FC blocks send to a slave
in alternation. Errors of a request are shown on the respective slave block.
TOP

Modbus_V2_04_RTU_001.docx Page 117 of 123


Modbus_V2_04

7.5 Adapter serial driver

The connection of an Inline interface is illustrated here. The blocks of the ComSerial library
are instantiated and connected with the adapter blocks. The parametrization of the serial
interface is done in the PC Worx worksheet by variables, differently than with Axioline in the
startup parametrization.
In addition to the serial interface, master and FC blocks are inserted. The execution order is
not specified.
TOP

Modbus_V2_04_RTU_001.docx Page 118 of 123


Modbus_V2_04

7.6 Slave functionality

The slave block is connected just like the master block to the serial driver via the structure
udtSerialIF.
TOP

Modbus_V2_04_RTU_001.docx Page 119 of 123


Modbus_V2_04

7.7 Multiple Inline slaves in the same network


The Inline modules as slaves need relatively longer time to process the received data in
comparison with Axioline or other devices. If more than one Inline slave are connected in the
same network, and the master is sending at a rapid pace, then it is possible that the received
telegrams by the Inline slave are overlapped. A time interval between requests should be
defined according to the slowest slave in the network.
In this example, a request is sent each second to a slave. A rising edge and the variable
xSendRequest_FC3 will start the sequence.

TOP

Modbus_V2_04_RTU_001.docx Page 120 of 123


Modbus_V2_04

8 Appendix A (Sending requests with MB_RTU_FCx_V2_01)


As previously mentioned, it is generally valid that all additional specifications for a request
have to be entered in the correct sequence in the array arrRegisterValues. If a request does
not require all the parameters, then these can be ignored or left unfilled.

Request configuration/Function code

Function code Parameters Input


Function code 1
Slave address uiSlaveAddress
Function code iFunctionCode
Start address uiStartAddress
Number of outputs iDataCount
Function code 2
Slave address uiSlaveAddress
Function code iFunctionCode
Start address uiStartAddress
Number of inputs iDataCount
Function code 3
Slave address uiSlaveAddress
Function code iFunctionCode
Start address uiStartAddress
Number of registers iDataCount
Function code 4
Slave address uiSlaveAddress
Function code iFunctionCode
Start address uiStartAddress
Number of registers iDataCount
Function code 5
Slave address uiSlaveAddress
Function code iFunctionCode
Start address uiStartAddress
Output value arrRegisterValues[1], first word of the array
True: FFFFhex
False: 0000hex
Function code 6
Slave address uiSlaveAddress

Modbus_V2_04_RTU_001.docx Page 121 of 123


Modbus_V2_04

Request configuration/Function code

Function code Parameters Input


Function code iFunctionCode
Start address uiStartAddress
Register value arrRegisterValues[1], first word of the array
Function code 15
Slave address uiSlaveAddress
Function code iFunctionCode
Start address uiStartAddress
Number of outputs iDataCount
Output values Write the desired bits as bytes in the array
arrRegisterValues, starting with the high byte and
then the low byte.
If, for example, eight bits should be set to true,
then FF is set in the first word for the high byte.
(arrRegisterValues[1] = FFxxhex ).
Function code 16
Slave address uiSlaveAddress
Function code iFunctionCode
Start address uiStartingAddress
Number of registers iDataCount
Register values Write the desired values of the addressed
registers in the array arrRegisterValues.
Function code 23
Slave address uiSlaveAddress
Function code iFunctionCode
Read starting address uiStartingAddress
Quantity to read iDataCount
Write starting address arrRegisterValues[1], first word of the array
Quantity to write arrRegisterValues[2], second word of the array
Data to write arrRegisterValues[3], as of the third word of the
arrays

TOP

Modbus_V2_04_RTU_001.docx Page 122 of 123


Modbus_V2_04

9 FAQ
9.1 Interval between requests
The Modbus slaves need different times for the processing of requests. The time interval
between multiple requests must be adjusted to the slowest slave, in order to avoid
overlapping of received telegrams.

9.2 Cycle time and PROFINET update time for inputs and outputs
The task cycle time and the PROFINET update time for inputs and outputs should be
adjusted to each other. Generally, the PROFINET update time should be faster than the task
cycle time.
Example : task cycle time: 10 ms PROFINET update time: 8 ms
Bad example : task cycle time: 5 ms PROFINET update time: 32 ms

9.3 xActive is False


Make sure that the master and the serial driver modules are enabled.

Modbus_V2_04_RTU_001.docx Page 123 of 123

S-ar putea să vă placă și