ELCOR-2 - Implementation of ModBus Protocol - Ver8
ELCOR-2 - Implementation of ModBus Protocol - Ver8
Rev. 8
1
Implementation of Modbus protocol in ELGAS devices
You may find description of ModBus protocol for the firmware of ELCOR-2, DATCOM-2,
DATCOM-RTU, DATCOM-AMR2, DATCOM-K4 and others. Information mentioned in
this manual are valid for firmware version 1.16, implementation of Modbus 1.02 version.
The fifth edition of the document was specified for implementation version 1.04 and FW
version miniELCOR 4.05 and picoELCOR 1.01.
The seventh edition of the document was specified for the 4th generation devices, for the
implementation version 1.05 and the FW ELCOR version 1.10.
Information contained in this manual cannot be considered to be a legal obligation of the ELGAS, s. r.
o. company. Company ELGAS, s. r. o. reserves all rights to make changes as it sees fit. Changes to the
manual or to the product itself leading to the device improvements or to correction of typographic or
technical faults can be made at any time without notice.
2
Implementation of Modbus protocol in ELGAS devices
Contents
1 Introduction ........................................................................................................................ 5
2 Survey of ModBus protocol ............................................................................................... 5
2.1 Physical layer ............................................................................................................. 5
2.2 Transmission in ModBus network ............................................................................. 5
2.3 Implemented functions ............................................................................................... 6
2.3.1 Tunnel of ELGAS ver.2 protocol ........................................................................... 7
2.4 Map of internal registers ............................................................................................ 8
2.5 Map of discrete outputs .............................................................................................. 8
2.5.1 Survey of discrete outputs map to control the device ............................................ 9
2.6 Access rights .............................................................................................................. 9
2.6.1 Access rights for 4th generation devices .............................................................. 10
2.7 Error responses ......................................................................................................... 10
2.7.1 Error codes generated by device .......................................................................... 11
2.8 Particularities of implementation ............................................................................. 11
2.8.1 Service address ..................................................................................................... 11
2.8.2 Time of response .................................................................................................. 11
2.8.3 Calling the master system - sending a "CryOut message" ................................... 11
2.9 GasNatural variant.................................................................................................... 13
2.10 Modbus ENRON ...................................................................................................... 13
2.10.1 32-bit register area ............................................................................................ 13
2.10.2 Reading archives .............................................................................................. 13
3 Templates ......................................................................................................................... 14
3.1 Creation of template ................................................................................................. 15
3.2 MODBUS map variant ............................................................................................. 16
3.3 Saving of ModBus map to the device ...................................................................... 16
3.4 Data types used in the device ................................................................................... 17
3.5 Data type of individual quantities and parameters ................................................... 19
3.6 Options for data types conversion ............................................................................ 25
4 Bibliography ..................................................................................................................... 27
3
Implementation of Modbus protocol in ELGAS devices
Terms
4
Implementation of Modbus protocol in ELGAS devices
1 Introduction
In this manual may be found description of implementation of ModBus-RTU protocol for
ELCOR-2, DATCOM-2, DATCOM-RTU, mini-, midi-, maxi-, nano-, picoELCOR
(-DATCOM) (further the device only) and other devices from ELGAS, s.r.o. company
portfolio. The manual describes differences in 4th generation devices - ELCOR, ELCORplus
(hereinafter only 4th generation devices). All general information about protocol may be
found in original literature [1].
In the text is used Czech terminology. English equivalent is mentioned in brackets during
first presence of term. Digital values in the text are mentioned in decimal representation as far
as not sad otherwise. Whether the values are mentioned in hexadecimal representation then
are marked with suffix „h“ or in the header of table „hex“.
In the first part of text are mentioned some general characteristics given by definition of
implemented protocol with attention to particularities, see the chapter 2 Survey of ModBus
protocol.
Firmware of the device predominates with huge variability of configuration. Basic
element of ModBus protocol is map of internal registers (futher more ModBus map) which
display quantities of the device. Due to the great variability of the device, the possibility to
modify the Modbus map is implemented here. This is done through pre-prepared templates.
For more details, see 3 Templates.
5
Implementation of Modbus protocol in ELGAS devices
character follows idle interval on bus bar of the length of 3,5 characters which indicates the
end of the frame. After expiration of this interval may be transmitted next frame.
Complete frame may be transmitted as continuous stream without spaces. Whether idle period
will appear inside of the frame between the characters longer than time corresponding to
transmission of 1,5 character then receiving unit will ignore received part of the frame and
following character will be considered as first character of new frame.
Format of frame
Start Address Functional Data block CRC block End
idle length block block n characters 2 characters idle length
3,5 characters 1 character 1 character 3,5 characters
Address block
By query, the address block contains address of slave unit for which the query is determined
(slave address). By response, the address block contains address of slave unit which sent the
response.
Valid addresses for slave units are in the range 1 – 247. Address 0 is determined for a
broadcast . Any frame with address 0 is considered as a broadcast where all slave units has to
evaluate but none of them will answer to this broadcast .
Functional block
By query or broadcast, the functional block contains code of function (function code) which
shall be performed. By response, the functional block contains copy of function code which
slave unit received in query. Whether the most important bit of function code is set in the
response, it means, that during performing of command with slave unit appeared error and is
sent exception response. In such case data block contains code which closely specifies type of
error (exception code).
Data block
Data block contains different information in dependence on required or performed function.
CRC block
CRC block contains 16-bit cyclic security code (CRC) which is used for integrity test of
received frame.
6
Implementation of Modbus protocol in ELGAS devices
Response :
Byte No. Meaning Note Example (hex)
1 Address F8
2 Code of function 53
3 Length of data (LSB) length of data includig Type, 0B
Group and Port dest
4 Length of data (MSB) 00
5 Type from head of ELGAS ver.2 86
6 Group from head of ELGAS ver.2 6C
7 Port dest from head of ELGAS ver.2 00
8 Data data layer of ELGAS ver.2 35
8+n 17
10
09
11
05
7
Implementation of Modbus protocol in ELGAS devices
0C
3A
8
Implementation of Modbus protocol in ELGAS devices
The addresses in the Modbus map are given in the form 0xxxx (0x referencies), with the
possible first address 101.
Note: as part of the implementation of the Modbus protocol in the device, binary
quantities can be mirrored in the address space of discrete outputs (0x referencies, Modbus
functions 1 and 5) and in the address space of internal registers (4x referencies, Modbus
functions 3 and 10 hex).
9
Implementation of Modbus protocol in ELGAS devices
Data block
Data block contains data generated by concrete function in normal response. Data block
contains code of error which appeared in error response.
10
Implementation of Modbus protocol in ELGAS devices
11
Implementation of Modbus protocol in ELGAS devices
recipient in the event of a monitored event. The data is packed in the ELGAS ver.2 protocol
tunnel (see 2.3.1). After receiving a response from the master system, the device waits for
queries from the master system. In case of idle on the communication channel, it hangs up the
connection after the timeout expires and eventually switches off the modem.
12
Implementation of Modbus protocol in ELGAS devices
13
Implementation of Modbus protocol in ELGAS devices
The number of record registers can be configured in the template, for address 40702 the
registers located in the template in the "Data archive" tab are sent, for address 40703 the
registers located in the template in the "Daily archive" tab are sent. One archive record can be
read with one query.
Query:
Byte Meaning Remark Example
number (hex)
1 Address 01
2 Function code 03
3 Address (MSB) 701 .. data archive 02
702 .. daily archive
4 Address (LSB) BD
5 Index (MSB) Record index (not number of 00
registers !!!)
6 Index (LSB) 0A
7 CRC (LSB) 54
8 CRC (MSB) 51
Reply:
Byte Meaning Remark Example
number (hex)
1 Address 01
2 Function code 03
3 Data lenght
4 Data
5 …
n-1 CRC (LSB)
n CRC (MSB)
When trying to read a record that does not exist, the device returns the response "Invalid
response: Illegal data value".
3 Templates
There is option to modify ModBus map (map of internal registers) because of huge
variability of measured or calculated quantities according to configuration of the device and
customer´s needs. Template may be created for these purposes where is defined ModBus map
according to requirements. ModBus map concerning to concrete parameters is created during
configuration of the device by help of template.
14
Implementation of Modbus protocol in ELGAS devices
15
Implementation of Modbus protocol in ELGAS devices
For first two types of elements and archive values where is necessary to determine concrete
quantity may be identified quantity according to its address in visualization or according to
type (analog, binary, counter, ...) and its consecutive number.
Whether elements of Modbus map is connected to quantities through the visualization address
then change of this address in device parameters is blocked so it is not possible to modify the
address. It will also prevent error of Modbus map. By this way of identification the quantities
may be added, removed, changed their consecutive number without impact to Modbus map
and its template.
For the second way where the elements of Modbus map are connected to quantities through
their types and consecutive number, Modbus map will be automatically updated by
application TELVES and the user will be notified that Modbus map was adjusted and that the
map no longer matches the template from which it was created. In this case visualization
address may be used for different purposes.
- for Modbus function 1 means the bit number of the device status word from which the
value is taken
Type – required data type – chapter 3.4 Data types used in the device
Digit – multiplicative conversion constant
Offset – aditive conversion constant
Final value of ModBus will be following:
Digit * original value of the device + Ofset.
16
Implementation of Modbus protocol in ELGAS devices
object of parametrization / Address of ModBus map“. This menu will be displayed after
pressing the right button on the mouse and „Calculated measurands“ has to be selected.
Application also require to select template according to which will be mapped elements of
ModBus into address field. It is necessary to be aware that any changes can not be done into
already existing ModBus map, means to add, delete or change some elements. Change of map
may be performed by removing and creating new map. It may be done manually or by
restoring of revised template with relevant button.
Setting is finished by writing of parameters to the device.
Several different data types are used to represent values and parameters in the device's
internal registers:
BYTE An 8-bit unsigned value in the range 0 to 255. The value is stored in the
lower byte of the 16-bit register. The higher byte of the registry is ignored,
but it is recommended to always write it as 00h.
WRD 16-bit unsigned value in the range 0 to 65535
WRDrev 16-bit unsigned value in the range 0 to 65535, reverse order (2 bytes)
INT 16-bit signed value in the range -32768 to +32767
LNG A 32-bit unsigned value stored in two consecutive 16-bit registers. The
higher bits are stored in the register at address n, the lower bits are stored in
the register at address n + 1. Range 0 to 4294967295.
example: the number 318 is stored as 0h, 13Eh
LNGrev unsigned long (4 byte), reverse order
LNFL format consisting of two values, unsigned long (4 byte) - whole part of
number, float (4 byte) - decimal part
LNFLrev format consisting of two values, unsigned long (4 byte) - whole part of
number, float (4 byte) - decimal part, reverse order
LNGTOT unsigned long (4 byte), for converting double to long format, with 9-digit
trimming (decimal)
LNGLNG 2 consecutive LNG formats (8 bytes)
LNG64 Unsigned long64 (8 byte)
FLT 32-bit single-precision floating-point value with simple accuracy, stored in
two consecutive 16-bit registers
example: 0.01 is stored as 3C23h, D70Ah
FLTrev float (4 byte), reverse order
17
Implementation of Modbus protocol in ELGAS devices
FLTswp float (4 bytes), rearranged order (1st with 2nd and 3rd with 4th byte)
FLTswr float (4 bytes), reversed and rearranged order (1st with 2nd and 3rd with 4th
byte)
RFLT float (4 bytes), the decimal remainder of the value in float format
DBL 64-bit high-precision floating-point value stored in four consecutive 16-bit
registers
example: the number 0.01 is stored as 3F84h, 7AE1h, 47AEh, 147Bh
DT1 date and time stored in 6 bytes in BCD format in three consecutive 16-bit
registers
example: 15:28:54 09.11.2005 is saved as 5428h, 1509h, 1105h
DT2 date and time stored in 6 bytes in BCD format in three consecutive 16-bit
registers, the order is reversed than in the case of DT1 format
DT3 time and date in unsigned long format (number of seconds since 00:00:00
1.1.1970)
DT4 time and date in BCD format (6 registers)
example: 7/16/2013 2:06:41 PM saved as 000Dh 0007h 0010h 000Eh 0006h
0029h
DT5 date and time stored in 6 bytes in BCD format in three consecutive 16-bit
registers identical to DT1, in addition it transmits information about DST
(System Daylight Saving Time)
example: 7/16/2013 3:26:22 PM LČ is saved as 2226h D516h 0713h
DT6 date and time stored in 7 consecutive 16-bit registers
example: Tuesday 7/16/2013 2:17:17 PM is saved as 0011h 0011h 000Eh
0010h 0007h 07DDh 0002h (day of the week 0..6, sunday = 0)
DT7 date in MMDDYY format saved in float format (2 registers)
DT8 time in HHMMSS format stored in float format (2 registers)
DT9 time in MMDDYY and HHMMSS format stored in 2 x float format (4
registers)
BCD4 ulong number converted to BCD number, stored in two 16-bit registers
String a string stored in the form of ASCII characters in 16-bit registers, if the
length of the string does not reach the length of the defined field, the string is
terminated by the character 0h, the following characters are insignificant.
The following lengths are used: S3, S6, S8, S9, S12, S16, S32, S48, S80
StringR a string stored in ASCII characters in 16-bit right-aligned registers, the
following lengths are used: S16
Event Status (ulong GasNatural) and time in DT3 format - especially for use in the
GasNatural template
18
Implementation of Modbus protocol in ELGAS devices
Order of bytes is according to Modbus specification „Big Endian“, means that MSB is on
lower address than LSB, unless "reverse order" is given for each type..
19
Implementation of Modbus protocol in ELGAS devices
20
Implementation of Modbus protocol in ELGAS devices
Meaning of individual bit of actual and summary status (extended from bit b32) :
Bit Descriptiopn Remark
number
b0 FW checksum error
b1 Loader checksum error
b2 Device parameters checksum error
b3 Device RAM memory error
b4 Device time synchronization error
b5 Setting archive full – E5.
b6 Transducer has been replaced or its parameters have been ELCOR-2 only
modified
b7 Transducer communication error
b8 Transducer failure
b9 Battery voltage below acceptable level
b10 Error of compressibility table calculation caused by input
parameters
21
Implementation of Modbus protocol in ELGAS devices
1)
The device evaluates the current taken from two circuits - the terminals of the transducers and the expansion
connector. If an excessive load is connected to one of the circuits, the device will automatically disconnect this
circuit from the power supply. Reconnection is performed periodically once per hour. The user can call up the
connection by selecting in the "Device reset" menu.
22
Implementation of Modbus protocol in ELGAS devices
Meaning of individual bits of instantaneous, summary status and status in archives for 4th
generation devices:
23
Implementation of Modbus protocol in ELGAS devices
24
Implementation of Modbus protocol in ELGAS devices
Data types of Bit Byte Uint Ulong Float Double DT1 String
firmware .
Data types of
ModBus
BIT yes yes yes yes yes yes no no
BYTE yes yes yes yes yes yes no no
WRD yes yes yes yes yes yes no no
25
Implementation of Modbus protocol in ELGAS devices
26
Implementation of Modbus protocol in ELGAS devices
4 Bibliography
[1] Modicon Modbus Protocol Reference Guide, Modicon Inc., Industrial Automation
Systems, 1996
[2] Telves.exe
27
Implementation of Modbus protocol for ELCOR-2, DATCOM-2, DATCOM-RTU,
DATCOM-AMR2, DATCOM-AMR3, picoELCOR, nanoELCOR, miniELCOR,
midiELCOR, maxiELCOR, ELCOR, ELCORplus
Programmer’s manual
Elaborated by: Zdeněk Brancuský
Issued by: ELGAS, s. r. o. tel.: +420 466 414 500, 511
Ohrazenice 211 fax: +420 466 411 190
533 53 Pardubice http://www.elgas.cz
Czech republic e-mail: [email protected]
Issued: September 2020
Revision: eighth