You are on page 1of 26

Messung Systems NEXGEN PLC Libraries

NEXGEN Series of PLCs


Modbus RTU Library Manual

Document No.:ED-2002-045

Version: 1.0

Published September 2002

MESSUNG SYSTEMS
EL-2, J- Block MIDC Bhosari,
Pune – 411026.(INDIA)

Tel: (+91)-020-7120807, 7122807.


Email : marketing@ms.messung.com
WEB: www.messung.com

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 1 of 26
NEXGEN PLC Libraries Messung Systems

Revision

Version Date Description

1.0 26 October 2001 Modbus RTU Library Manual,

Warning !

The specifications of product and contents of manual


are subject to change without notice.

Published September 2002 Modbus RTU Library Manual


Page 2 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

INDEX

1. INTRODUCTION ......................................................................................................................... 5
2. RTU_SLAVE (FB) ........................................................................................................................ 7
2.1 PLC VARIABLES AND RANGE SUPPORTED BY FB .................................................................... 9
2.2 MEMORY MAPPING FOR PROCESSOR 521X............................................................................. 10
3. RTU_MASTER (FB)................................................................................................................... 12
3.1 PLC VARIABLES AND RANGE SUPPORTED BY FB .................................................................. 18
APPENDIX 1 RTU_COMSET.......................................................................................................... 19
APPENDIX 2 PLC VARIABLES AND RANGE SUPPORTED BY PROCESSOR 521X......... 22
APPENDIX 3 MODBUS COMMANDS SUPPORTED BY FB ..................................................... 23

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 3 of 26
NEXGEN PLC Libraries Messung Systems

Published September 2002 Modbus RTU Library Manual


Page 4 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

1. Introduction

The Modbus RTU FB library is designed to configure the on-board serial


ports of Nexgen5000 series CPUs as Modbus protocol port. Various modules
in Nexgen5000 series, provides upto 3 serial ports with open protocol
feature. The Modbus RTU library FBs are compatible with all these ports and
extends the facility of handling these ports like MODBUS ports.

• Port 1 – This is basically used as programming port when connected


to CoDeSys. Alternatively, it can also be used in open protocol
mode.
• Port 2 – This port is used as port with open protocol.
• Port 3 – This port is used as port with open protocol.

Depending on the CPU model, ports Com1, Com2 and Com3 are available.
Please refer to Nexgen5000 CPU user manual for model wise features. All
the three serial ports support open protocol and user can communicate with
any third party device using communication driver functions.

In Nexgen5000 series, the Protocol and Application layers in standard OSI


model of communication can be defined by using any of the 5 IEC
programming languages. The MODBUS FB library is one of such protocol
FBs. The library consists of two main FBs namely “RTU_Slave” and
“RTU_Master” .

Modbus, A standard protocol

Modbus protocol is one of the standard and most commonly used serial
protocols in Industrial communication. The protocol was introduced by
Modicon Inc. for communicating between multiple intelligent devices and was
then opened for everybody’s use.

Modubus protocol document defines two types of protocols namely :

• Modbus RTU protocol - 8 bit binary data transfer protocol


• Modbus ASCII protocol - 7 bit data transfer protocol using ASCII
characters

Both Modbus protocols are supporting multi-drop, Master-Slave, Half duplex


protocols. The physical layer specifications are open and thus one can
configure the system using RS232C, RS422, RS485, fiber optic or even
wireless media as physical layer depending on the application.

More details of the protocol and the standard protocol document can be
downloaded from website www.modbus.org

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 5 of 26
NEXGEN PLC Libraries Messung Systems

Highlighting Features of MODBUS RTU_slave FB

• User need not know the Modbus protocol


• Protocol implementation is physical layer independent i.e. it can be
used with RS232C, RS422 or RS485.
• Communicates with any third party Modbus RTU master or Messung
PLC with Modbus RTU_Master FB
• Easy connection to various SCADA and HMI packages. No need to
develop any special driver.
• Easy connection to Beijer E-terminals with it’s Modbus Master driver
• Allows to exchange data via I, Q and M devices in Nexgen.
• Ready to use FB with few parameters to define to go
• Flexibility in station number programming.
• Supports variety of baud rates to suit the application needs.

Highlighting Features of MODBUS RTU_slave FB

• User need not know the Modbus protocol.


• Protocol implementation is physical layer independent i.e. it can be
used with RS232C, RS422 or RS485.
• Communicates with any third party Modbus RTU slaves inclusive of
Messung PLCs with Modbus RTU_Slave FB
• Easy connection to various SCADA and HMI packages as slaves is
possible with appropriate drivers. No need to develop any special
driver.
• Easy connection to multiple Beijer E-terminals with it’s Modbus Slave
driver
• Easy application interface by defining data exchange records with
various stations
• Allows exchanging data via I, Q and M devices in Nexgen with
Modbus devices in various stations
• Data exchange records can be grouped and called in manual, auto-
cyclic and super-cyclic modes.
• Flexibility in data exchange records programming.
• Programmable Retry and Time-out facility if a station fails to
respond.
• Supports variety of baud rates to suit the application needs.

These FBs are useful

• To interface Beijer make E terminals as master or slave with Modbus


RTU Driver.
• To interface any SCADA software as master or slave which supports
Modbus RTU protocol.
• For PLC to PLC communication in Nexgen 5000 PLC. One PLC can
be a Master PLC and other/s can be slave/s.

The subsequent topics discuss how to program and use FBs.

Beijer make E terminal has RS-232 and RS-422 hardware interface and it
can be connected to RS-232 or RS-422 hardware interfaces with different
serial link cables..

Published September 2002 Modbus RTU Library Manual


Page 6 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

2. RTU_SLAVE (FB)

This FB handles serial communication with


Modbus RTU Protocol as slave device.
The RTU slave FB is useful to communicate
with any external master PLC, SCADA or
DCS systems.

One need not study the Modbus protocol


document to use this FB, just a few parameter
definitions to go!

Description of Parameters-

PORT VAR_IN BYTE This input byte holds communication port number to
be activated with Modbus RTU slave FB. It should
contain constant value of 1 or 2 or 3 for Port 1, Port
2, Port 3 respectively. Any other value is invalid.
SNO VAR_IN BYTE This input byte hold the station number. Valid range
is from 1 to 247. For invalid station number above
247, FB is not executed. Apart from the commands
received for this station, the broadcast commands
(station number as 0) are also executed.
COMSET VAR_IN RTU_Comset This is input variable of user defined data type
RTU_Comset. It defines communication parameter
settings like baud rate, parity, operation mode, etc
for a slave device. Appendix 1 provides the details of
various communication parameter settings.

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 7 of 26
NEXGEN PLC Libraries Messung Systems

Status VAR_OUT BYTE This output BYTE holds the status of execution
Status.0 This bit is TRUE when port is opened
successfully with the communication
parameters assigned.
Status.1 This bit is TRUE if checksum error is observed
in recent reception.
Status.2 This bit is TRUE if timeout of 1 sec is observed
in recent reception.
Replies VAR_OUT WORD This word holds number of healthy replies send to the
commands received from master. After 65535, value rolls
over to 0.
STN_Errs VAR_OUT WORD This word holds number of commands with different
station numbers received from master. After 65535, value
rolls over to 0. User should take proper action if such
errors are detected.
FNC_Errs VAR_OUT WORD This word holds number of invalid function code in
command received from master. After 65535, value rolls
over to 0. User should take proper action if such errors
are detected.

Example –

This example shows initialization of communication port 2 with


communication parameters 9600, Odd, 8, 1 and half duplex mode. Here,
baud rate group selected is 0.

Published September 2002 Modbus RTU Library Manual


Page 8 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

2.1 PLC Variables and Range Supported by FB

Modbus protocol accesses PLC variables as 0nnnn (coils), 1nnnn (input


bits), 3nnnn ( input registers) and 4nnnn ( holding registers). PLC Variables
supported by RTU_Slave FB for read and write operations are listed below
along with the addressing ranges.

Variable Range
Coils 00001 to 12048
Input bits 10001 to 11024
15001 to 17048 ( Range extended from 15000 to 17048 for Output bits)
Input Registers 30001 to 30128
35001 to 35128 ( Range extended from 35001 to 35128 for Output Registers)
Holding Registers 40001 to 47936

For Modbus protocol, variable addresses start from 1. For the variables defined
with address 0 ( 00000, 10000, 30000, 40000 ) are ignored.

Modbus_SLAVE FB supports Modbus RTU commands with function codes


explained in Appendix 3.

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 9 of 26
NEXGEN PLC Libraries Messung Systems

2.2 Memory Mapping for Processor 521x

Processor 5000 supports PLC variables as %I (inputs), %Q (outputs) and


%M (markers). The table in Appendix 2 shows PLC variables supported by
Processor 521x along with the addressing ranges.

The variables supported by RTU_SLAVE FB are mapped in such a way that


entire range of PLC variables of Nexgen 5000 Processor can be accessed
with Modbus protocol. The variables I (Input), Q (Output) and M (Marker) are
mapped as 0nnnn (coils), 1nnnn (input bits), 3nnnn ( input registers) and
4nnnn ( holding registers). The table below shows the memory mapping of
PLC variables.

Nexgen 5000 Processor supports 2048 Input BOOLs from %IX0.0 to %IX255.7.
They are mapped from 10001 to 12048.
Here, input bit variable %IXmmm.n is mapped at Modbus variable
10001+(mmm*8)+n
Mmm is byte number from 0 to 255 and n is bit number from 0 to 7.
Variable Range Mapping in 1nnnn Variables
Input %IX0.0 to %IX0.7 10001 to 10008
BOOL %IX1.0 to %IX1.7 10009 to 10016
%IX2.0 to %IX2.7 10017 to 10024

%IX255.0 to %IX255.7 12041 to 12048


Nexgen 5000 Processor supports 128 Input WORDs from %IW0 to %IW254. They
are mapped from 30001 to 30128.
Here, input word variable %IWmmm is mapped at Modbus variable
30001+(mmm/2)
Mmm is word number from 0, 2 to 254.
Variable Range Mapping in 3nnnn Variables
Input %IW0, %IW2 to %IW254 30001, 30002 to 30128
WORD
Modbus protocol does not support any output type of PLC variables directly. To
use this protocol conveniently with Processor 521x, output variables (%Q) are
mapped in input variable area (1nnnn ( BOOL ) and 3nnnn ( WORD)).
Nexgen 5000 Processor supports 2048 Output BOOLs from %QX0.0 to
%QX255.7. They are mapped from 15001 to 17048.
Here, output bit variable %QXmmm.n is mapped at Modbus variable
15001+(mmm*8)+n
Mmm is byte number from 0 to 255 and n is bit number from 0 to 7.
Variable Range Mapping in 1nnnn Variables
Output %QX0.0 to %QX0.7 15001 to 15008
BOOL %QX1.0 to %QX1.7 15009 to 15016
%QX2.0 to %QIX2.7 15017 to 15024

%QX255.0 to %QX255.7 17041 to 17048


Nexgen 5000 Processor supports 128 Output WORDs from %QW0 to %QW254.
They are mapped from 35001 to 35128.
Here, output word variable %QWmmm is mapped at Modbus variable
35001+(mmm/2)
Mmm is word number from 0, 2 to 254.
Variable Range Mapping in 3nnnn Variables
Output %QW0, %QW2 to %QW254 35001, 35002 to 35128
WORD

Published September 2002 Modbus RTU Library Manual


Page 10 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

Nexgen 5000 Processor supports 126976 Marker BOOLs from %MX0.0 to


%MX15871.7. Out of this range, 65536 BOOLs from %MX0.0 to %MX8191.7 can
be accessed as 00001 to 65536. The remaining BOOLS up to %MX15871.7 can
not be accessed.
Here, input bit variable %MXmmm.n is mapped at Modbus variable
410000+(mmm*8)+n
Mmm is byte number from 0 to 1249 and n is bit number from 0 to 7.
Variable Range Mapping in Coils
Marker %MX0.0 to %MX0.7 00001 to 00008
BOOL %MX1.0 to %MX1.7 00009 to 00016
%MX2.0 to %MX2.7 00017 to 00024

%MX1248.0 to MX1248.7 19985 to 19992


%MX1249.0 to MX1249.7 19993 to 19999
Nexgen 5000 Processor supports 7936 Marker WORDs from %MW0 to
%MW15870. They are mapped as 40001 to 47936.
Variable Range Mapping in Holding registers
Marker %MW0, %MW2 to 40001, 40002 to 47936
WORDs %MW15870

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 11 of 26
NEXGEN PLC Libraries Messung Systems

3. RTU_MASTER (FB)

This FB handles serial communication with


Modbus RTU Protocol as master device.
It is useful to interface HMI, SCADA as
a slave with Nexgen 5000 PLC.

Description of Parameters-

PORT VAR_IN BYTE This input byte holds communication port number to be
activated with Modbus RTU slave FB. It should contain
constant value of 1 or 2 or 3 for Port 1, Port 2, Port 3
respectively. Any other value is invalid.
COMSET VAR_IN RTU_Comset This is input variable of user defined data type
RTU_Comset. It defines communication parameter
settings like baud rate, parity, operation mode, etc for a
master device. Appendix 1 provides the details of various
communication parameter settings.
GrSel VAR_IN BYTE This byte selects the sequence of sending commands
defined by array of records of type RecStruct.
0 This selects manual mode of operation. The
command defined by RecNo is sent once at rising
edge of Start input.
1 This selects auto mode of operation. The commands
with Gr=1 defined in array of records of type
RecStruct are sent one by one cyclically.
>1 This selects auto mode of operation. The commands
with Gr=1 and Gr=GrSel defined in array of records
of type RecStruct are sent one by one cyclically.
RecNo VAR_IN BYTE This byte holds record number in array of records of type
RecStruct to be sent is manual mode. In auto mode, this
input is ignored.
Start VAR_IN BOOL FB sends command defined by RecNo in manual mode at
rising edge of Start input. If a particular slave device is not
responding, FB retries as explained earlier. In auto mode,
this input is ignored.

Published September 2002 Modbus RTU Library Manual


Page 12 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

AdrRecTable VAR_IN POINTER This is address pointing to an array of records of type


TO RecStruct. These records define command format. These
RecStruct records are analyzed by FB for validity in sequence
starting from first record and accordingly commands are
initiated depending upon mode of operation selected by
GrSel input.. The user defined data type RecStruct is
defined as shown below

TYPE RecStruct :
STRUCT
Gr: BYTE;
FNC:BYTE;
SNo :BYTE;
LDT : TT;
LAdr: WORD;
RAdr:WORD;
DLen:BYTE;
END_STRUCT
END_TYPE
Gr BYTE The command can be grouped for
sending an auto mode or manual
mode..
0- Normally, command with group
number 0 is sent once when
manual mode is initiated.
1- By default, commands with group
number 1 are sent cyclically in auto
mode. These group commands
also can be sent in manual mode.
<1- The commands with group
number defined in GrSel are sent
cyclically along with commands
with group number 1 in auto mode.
These group commands also can
be sent in manual mode.
FNC BYTE This byte defines the function code for
command as per Modbus protocol. The
function codes supported by FB are
given below. Appendix 3 provides more
details.
01 Read Coil Status
02 Read Input Status
03 Read Holding Register
04 Read Input Registers
05 Force Single Coil
06 Preset Single Register
15 Force Multiple Coils
16 Preset Multiple Registers

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 13 of 26
NEXGEN PLC Libraries Messung Systems

SNo BYTE This byte holds station number of slave


device to which particular command is
to be sent. It should be in the range of
1 to 247. 0 is reserved for the broadcast
address. The command with station
number 0 are received by all the slave
devices. After a broad cast, FB waits for
the time duration defined by TimeOut
and after that next command is sent.
Only write type of commands ( with
function code 05, 06, 15 and 16 ) can
be broadcasted.
LDT TT This defines PLC variable type for FB
which is considered as local.
This is enumerated variable of type TT
which is defined as
TYPE TT :
( Q:=0, I:=1,M:=2);
END_TYPE
0 Q Output area
1 I Input area
2 M Marker area
LAdr WORD This word holds start address of PLC
variable area (defined by LDT) in
Processor 521x. After any read type of
command, the data received from slave
device is stored in PLC variable area
with this start address. For any write
type of command, data is picked up
from PLC variable area with this start
address which is sent to slave device.
The local address ranges are defined in
Appendix 2
RAdr WORD This word holds Modbus address.
Modbus address is defined by FNC and
RAdr. RAdr is offset within variable type
( variable type is defined by FNC) in
slave device. Any read type of
command requests for data from
variable type with this offset in the slave
device. Any write type of command
sends data which is written to variable
type with this offset.
DLen BYTE This byte holds number of data types
(BOOL or WORD) to be read or written.
Commands with function code 01, 02,
05 and 15 refer to BOOL type of
variables. Commands with function
code 03, 04, 06, 16 refer to WORD type
of variables.
Command with function code 05 refers
to a single BOOL variable where as
command with function code 06 refers
to a single WORD variable.

Published September 2002 Modbus RTU Library Manual


Page 14 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

MaxRec VAR_IN BYTE This byte holds total number of records in an array.
Status VAR_OUT BYTE The bits in byte returns the status of FB as below.
Bit Significance
0 Recent record executed successfully
1 Checksum error in reception.
2 Timeout error
3 Unknown FNC in RecTable
4 End of RecTable reached
LastRec VAR_OUT BYTE This byte holds the index of Records which is recently
executed.
LastResult VAR_OUT BYTE This BOOLean variable holds the result of execution of
last record.

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 15 of 26
NEXGEN PLC Libraries Messung Systems

Example 1-

This example shows initialization of communication port 3 with


communication parameters 9600, Odd, 8, 1 and full duplex mode. Here,
baud rate group selected is 0. The definition of Records is as shown in figure.

When FB is executed, commands defined by records are sent one by one


starting from first record (Records[0]) in auto mode.. Here, when GrSel is 1 or
greater than 1, all the records with Gr 1 are executed one by one in auto
mode.

First record in the array sends command to write ( as FNC is 16) contents of
local marker word %MW10 to remote Modbus slave (station number 1)at
holding register 40100.

Second record in the array sends command to write ( as FNC is 16) contents
of local marker word %MW12 to %MW18 ( 4 words) to remote Modbus slave
(station number 1)at holding register 40101, 40102, 40103, 40104
respectively.

Third record in the array sends command to read ( as FNC is 3) contents of


remote Modbus slave (station number 1) from holding register 40105 to
40109 and the contents are stored at local marker variables %MW20 to
%MW28.

Published September 2002 Modbus RTU Library Manual


Page 16 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

When GrSel is 2, all the records with Gr 2 are executed one by one along
with the records with Gr 1.

Fourth record in the array sends command to read ( as FNC is 3) contents of


remote Modbus slave (station number 1)from holding register 40100 and the
contents are stored at local marker variables %MW30.

Fifth record in the array sends command to read ( as FNC is 3) contents of


remote Modbus slave (station number 1)from holding register 40101, 40102,
40103, 40104 and the contents are stored at local marker variables %MW32,
%MW34, %MW36, %MW38 respectively.

Sixth record in the array sends command to write ( as FNC is 16) contents of
local marker word %MW20 to %MW28 ( 5 words) to remote Modbus slave
(station number 1)at holding register 40110 to 40114.

The following figure shows the data exchange.

%MW10 Records[0] writes %MW10 to 40100 40100

%MW12 40101
%MW14 Records[1] writes %MW10 - %MW18 to 40102
%MW16 40101 - 40104 40103
Gr 1 %MW18 40104
commands
%MW20 40105
%MW22 40106
Records[2] reads 40105 – 40109 to
%MW24 40107
%MW20 - %MW28
%MW26 40108
%MW28 40109

%MW30 Records[3]reads 40100 to %MW30 40100

%MW32 40101
%MW34 Records[4] reads 40101 – 40104 40102
%MW36 to%MW32 - %MW38 40103
Gr 2 %MW38 40104
commands
%MW20 40110
%MW22 40111
Records[5] writes %MW20 - %MW28
%MW24 To 40110 – 40114 40112
%MW26 40113
%MW28 40114

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 17 of 26
NEXGEN PLC Libraries Messung Systems

3.1 PLC Variables and Range Supported by FB

Modbus protocol accesses variables from slave device/s as 0nnnn (coils),


1nnnn (input bits), 3nnnn ( input registers) and 4nnnn ( holding registers).
PLC Variables supported by RTU_MASTER FB for read and write operations
are listed below along with the addressing ranges.

Variable Range
Coils 00001 to 09999
Input bits 10001 to 19999
Input Registers 30001 to 39999
Holding Registers 40001 to 49999

For Modbus protocol, variable addresses start from 1. For the variables defined
with address 0 ( 00000, 10000, 30000, 40000 ) are ignored.

Published September 2002 Modbus RTU Library Manual


Page 18 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

Appendix 1 RTU_ComSet

This is user defined data type provided in Modbus library. The definition of
this user defined data type along with default values is as shown below.

TYPE RTU_ComSet :
STRUCT
ComSet : WORD:=16#4305;
TX_delay : BYTE := 0;
RX_Delay :BYTE := 0;
Time_out : TIME:= t#1s;
RetryCount : BYTE:=1;
END_STRUCT
END_TYPE`

First member ComSet defines basic communication parameters. The table


for ComSet explains the communication parameter settings for FBs
‘RTU_SLAVE and ‘RTU_MASTER’.

Bits F E D C B A 9 8 7 6 5 4 3 2 1 0
ComSet is a word for
Receive Buffer Initialization
Baud Rate Group selection

communication parameter setting.


Various bit combinations in a word
Communication Mode

decides communication
Software Handshake

parameters of a serial port.

No. Of Data Bits


No. Of Stop bits

Baud Rate
Parity

Baud Rate Bits Hexadecimal


Lower byte (Bit 0 to 7) of ComSet Baud Rate
Value
decides the baud rate 7 6 5 4 3 2 1 0
300 0 0 0 0 0 0 0 0 16#0
600 0 0 0 0 0 0 0 1 16#1
1200 0 0 0 0 0 0 1 0 16#2

2400 0 0 0 0 0 0 1 1 16#3

4800 0 0 0 0 0 1 0 0 16#4

9600 0 0 0 0 0 1 0 1 16#5
14400 0 0 0 0 0 1 1 0 16#6
19200 0 0 0 0 0 1 1 1 16#7

28800 0 0 0 0 1 0 0 0 16#8

38400 0 0 0 0 1 0 0 1 16#9

57600 0 0 0 0 1 0 1 0 16#A

115200 0 0 0 0 1 0 1 1 16#B

230400 0 0 0 0 1 1 0 0 16#C

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 19 of 26
NEXGEN PLC Libraries Messung Systems

F E D C B A 9 8
No. of Data Bits 7 data bits 0
Bit 8 decides number of data bits.
8 data bits 1
Parity No parity 0 0
Bits 9 and A decides parity.
Odd parity 0 1

Even parity 1 0

Invalid 1 1
No. of Stop Bits 1 stop bit 0
Bit B decides number of stop bits
2 stop bit 1
Communication Mode
Bit C decides communication
mode. If half duplex mode is Half duplex 0
selected, reception is disabled
during transmission and vice versa.
For full duplex mode, reception is
possible during transmission and
vice versa. If full duplex mode is
selected for RS-485, echo is
Full duplex 1
received while transmission. User
should take care for handling such
communication.
Software Handshake XON/XOFF control disable 0
Bit D selects software handshake.
XON/XOFF control enable 1
Receive Buffer Initialization No Initialization 0

Initialization at every reception. 1


Baud Rate Group Selection Group 0 ( Normal Mode ) 0
Bit F selects baud rate group.
Group 1 ( Extended Mode ) 1
For baud rate selection, two Baud Normal Mode Extended Mode
combination modes normal and Rate (bF=0) (bF=1)
extended are provided for second Port 2 Port 3 Port 2 Port 3
and third serial port. Mode is
selected considering baud rate 300 Y Y Y Y
required for both communication 600 Y Y Y Y
port 2 and 3. It is not possible to
select two different modes for 1200 Y Y Y Y
communication port 2 and 3. If 2400 Y Y Y Y
different modes are selected for
two ports, second OPENPORT FB 4800 Y Y Y Y
in logic scan is not executed. The 9600 Y Y Y Y
table shows different baud rate
combinations possible for 14400 Y N Y N
communication port 2 and 3. 19200 Y Y Y N
28800 Y N Y N
38400 N N Y Y
57600 Y N Y N
115200 Y N Y N
230400 N N Y N

Published September 2002 Modbus RTU Library Manual


Page 20 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

Other members of user defined data type RTU_ComSet are explained in


table below

RxDelay BYTE RxDelay is a delay for starting reception after completion of any
transmission. This delay is active while receiving first byte after any
transmission. It is a character delay and varies according to
communication parameter settings. This is applicable only in half duplex
mode.
Actual time delay = (No. of parity bits+ No. of stop bits for transmission+
No. of data bits)*RxDelay / BPS
TxDelay BYTE TxDelay is a delay for starting transmission after completion of any
reception. This delay is active while transmitting first byte after any
reception. It is a character delay and varies according to communication
parameter settings. This is applicable only in half duplex mode.
Actual time delay = (No.of parity bits+ No. of stop bits for reception+
No. of data bits)* TxDelay / BPS
TimeOut TIME This parameter is applicable for RTU_MASTER FB. This is the time with 1
ms resolution within which a specific slave device should respond to a
command otherwise predefined retries are carried out . In case of
broadcast commands, master waits for the time duration defined by
TimeOut and after that master initiates next command.
RetryCnt BYTE This parameter is applicable for RTU_MASTER FB. This byte hold number
of retries FB should do if a specific slave device is not responding. If slave
device does not respond even after number of retries, communication error
for that slave device is confirmed.

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 21 of 26
NEXGEN PLC Libraries Messung Systems

Appendix 2 PLC Variables and Range Supported by Processor 521x

Processor 5000 supports PLC variables as %I (inputs), %Q (outputs) and


%M (markers). The table below shows PLC variables supported by
Processor 521x along with the addressing ranges.

Variable Type Data Type Range Quantity


Input BOOL %I X IX0.0 to IX0.7 2048
(X is optional) IX1.0 to IX1.7

IX255.0 to IX255.7
Input WORD %I W IW0, IW2, IW4 to IW254 128
Output BOOL %Q X QX0.0 to QX0.7 2048
(X is optional) QX1.0 to QX1.7

QX254.0 to QX254.7
Output WORD %Q W QW0, QW2, QW4 to QW254 128
Marker BOOL %M X MX0.0 to MX0.7 126976
(X is optional) MX1.0 to MX1.7

%MX15871.0 to %MX15871.7
Marker WORD %M W %MW0, %MW2, %MW4 to %MW15870 7936

Published September 2002 Modbus RTU Library Manual


Page 22 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

Appendix 3 Modbus Commands Supported by FB

Modbus_SLAVE and Modbus_MASTER FB support Modbus RTU


commands with function codes explained in table below.

Function
Variable Meaning Action
Code
01 Read Coil Status Obtains current status (TRUE/FALSE) of a
group of a coils
Coil 05 Force Single Coil Force coil to a status of TRUE or OFF.
15 Force Multiple Coils Force a series of consecutive coils to defined
TRUE or FALSE status
02 Read Input Status Obtains current status (TRUE/FALSE) of a
Input bit
group of digital inputs.
Input 04 Read Input registers Obtain current binary value in one or more input
Registers registers.
03 Read Holding Registers Obtain current binary value in one or more
holding registers.
Holding 06 Preset Single Register Write a specific binary value into a holding
Registers register.
16 Preset Multiple Registers Write specific binary values into a series of
consecutive holding registers.

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 23 of 26
NEXGEN PLC Libraries Messung Systems

Published September 2002 Modbus RTU Library Manual


Page 24 of 26 Document No.: ED-2002-045/V1.0
Messung Systems NEXGEN PLC Libraries

Modbus RTU Library Manual Published September 2002


Document No.: ED-2002-045 /V1.0 Page 25 of 26
NEXGEN PLC Libraries Messung Systems

MESSUNG SYSTEMS
EL – 2, J - Block, MIDC, Bhosari,
PUNE – 411 026. INDIA
Tel. – (+91) –020 – 712 0807, 712 2807
Fax. – (+91) –020 –712 0391

NEXGEN PLC Libraries


Modbus RTU Library Manual

Document No.:ED-2002-045

Published September 2002 Modbus RTU Library Manual


Page 26 of 26 Document No.: ED-2002-045/V1.0

You might also like