Instruction Manual Modbus Protocol: October 2013 Part No.: 4416.527 Rev. 4
Instruction Manual Modbus Protocol: October 2013 Part No.: 4416.527 Rev. 4
Instruction Manual Modbus Protocol: October 2013 Part No.: 4416.527 Rev. 4
ModbusTM Protocol
October 2013
Part no.: 4416.527
Rev. 4
Honeywell Enraf
P.O. Box 812
2600 AV Delft
Netherlands
Reproduction in any form without the prior consent of Enraf B.V. is not allowed.
This instruction manual is for information only. The contents, descriptions and specifications are
subject to change without notice. Enraf B.V. accepts no responsibility for any errors that may appear
in this instruction manual.
The warranty terms and conditions for Enraf products applicable in the country of purchase are
available from your supplier. Please retain them with your proof of purchase.
Preface
This manual has been written for the technicians involved with the
communication with the Honeywell Enraf series 880 communication
interface units via ModbusTM.
Legal aspects The information in this instruction manual is copyright property of Enraf
B.V., Netherlands.
Enraf B.V. disclaims any responsibility for personal injury or damage to
equipment caused by:
Additional information
Please do not hesitate to contact Honeywell Enraf or its representative if
you require additional information.
Table of Contents
Preface .................................................................................................................................................. 3
Introduction ............................................................................................................................................ 6
Function codes..................................................................................................................................... 12
Function code 01: Read coil status .............................................................................................. 12
Function code 02: Read input status ............................................................................................ 12
Function code 03: Read holding registers .................................................................................... 13
Function code 04: Read input registers........................................................................................ 14
Function code 05: Force single coil.............................................................................................. 14
Function code 06: Preset single register ...................................................................................... 15
Function code 08: Diagnostics ..................................................................................................... 15
Function code 15: Force multiple coils ......................................................................................... 16
Function code 16: Preset multiple registers ................................................................................. 17
Introduction
Modbus is the name given to a set of “rules” (procedures) to follow when
transferring data from one computer to another. Like two people
communicating with each other, they both must use the same language
and grammar to understand each other. Such a set of computer
communication rules is commonly called a “protocol”.
Modbus protocol defines the format of the data and the techniques used
to control the flow of data. Modbus communication can take place on
virtually any physical platform: RS-232, RS-485, modem-to-modem, etc.
Modbus protocol also specifies that the flow of data between two
devices uses a Master/Slave type arrangement. Multiple Modbus devices
may exist on the same common cable forming a Modbus network, but
only two devices will communicate at any one time, a master and a slave.
Each slave device on a Modbus network has its own unique address.
This address is sent by the master as part of every message. All slave
devices on the network see the message, but only the slave device with
the matching address will respond to the message.
A message sent to a slave from the master is called a query, the answer
sent back to the master is called a response. Query and response
messages are also called packets or frames.
Communication parameters
Controllers can be set up to communicate on standard Modbus networks
using RTU (Remote Terminal Unit) transmission mode.
Start bit 1
Data bits 8
Communication procedure
A Modbus message is placed by the transmitting device into a frame that
has a known beginning and ending point. This allows receiving devices to
begin at the start of the message, read the address portion and
determine which device is addressed, and to know when the message is
completed. Partial messages can be detected and errors can be set as a
result.
CRC
start address function data end
check
T1T2T3T4 8 bits 8 bits n * 8 bits 2 * 8 bits T1T2T3T4
All Modbus memory addresses in this document are given with their
hexadecimal value.
address The address field of a message frame contains eight bits. The individual
slave devices are assigned addresses in the range of 01...F7 (address 00
is NOT allowed). A master addresses a slave by placing the slave
address in the address field of the message. When the slave sends its
response, it places its own address in this address field of the response
to let the master know which slave is responding.
function The function code field of a message frame contains eight bits. Valid
codes are in the range of 01...FF. When a message is sent from a
master to a slave device the function code field tells the slave what kind
of action to perform.
When the slave responds to the master, it uses the function code field to
indicate either a normal (error-free) response or that some kind of error
occurred. For a normal response, the slave simply echoes the original
function code. For an exception response, the slave returns a code that is
equivalent to the original function code with its most significant bit set to a
logic “1”.
data The data field is constructed using sets of two 8 bit bytes (16 bit
registers), in the range of 0000...FFFF. The data field of messages sent
from a master to slave devices contains additional information which the
slave must use to take the action defined by the function code.
The data field can be non-existent (of zero length) in certain kinds of
messages. The function code alone specifies the action.
CRC check The CRC check field contains a 16-bit value implemented as two
eight-bit bytes. The error check value is the result of a CRC (Cyclical
Redundancy Check) calculation performed on the message contents. The
CRC field is appended to the message as the last field in the message.
Memory structures
Along with the slave address, the Modbus function code is another piece
of data that is in every query or response packet. This piece of data
specifies an action to be carried out by a Modbus slave device and the
memory range (coils, input registers, etc.) affected.
The standard address range runs from 0000...270F; Enraf extended this
range from 0000...FFFF for use within their systems.
In general there are four types of memory images that the Modbus host
can request:
Coils
Status inputs
Input registers
Holding registers
Coils
All coils are located in the memory range (0)0000...(0)FFFF. The value of
coils can be 1 = ON or 0 = OFF. Coils have read/write properties.
The address space of the coils and the discrete inputs are combined in
one 1 bit area occupying the addresses (0)0000...(0)7FFF. The data can
be read by using Modbus function code 01. Data for tank commands can
be written using the Modbus 05 and 15 commands.
Input status
Input statuses are located in the memory range (1)0000...(1)FFFF.
The value of input statuses can be 1 = ON or 0 = OFF. Input statuses are
considered to be discrete inputs. Input statuses are used to store tank
alarm conditions. Input statuses are read-only.
The address space of the coils and the discrete inputs are combined in
one 1 bit area occupying the addresses (1)0000...(1)7FFF. The data can
be read by using Modbus function code 02.
Input registers
Input registers are located in the memory range (3)0000...(3)FFFF.
Register values can range from 0000...FFFF since all registers are 16 bits
long. Input registers are used for analog inputs or to store values
collected from the field and calculated values (level, temperature, volume,
etc.). Input registers are read-only.
In the 16 bit registers space both the holding registers and the input
registers are combined in one address space occupying the standard
area from 0000...270F and the extended memory area from 2710
onwards. Data can be retrieved via Modbus function code 04.
Holding registers
Holding registers are located in the memory range (4)0000...(4)FFFF.
Register values can range from 0000...FFFF since all registers are 16 bits
long. Holding registers are used for analog outputs. Holding registers
have read/write properties.
In the 16 bit registers space both the holding registers and the input
registers are combined in one address space occupying the standard
area from 0000...270F and the extended memory area from 2710
onwards. Data can be retrieved via the Modbus function code 03. Via
Modbus commands 06 and 16 writing can be done to some registers.
Specifications for storing decimal (real, floating point, etc.) numbers and
negative numbers are not part of the original Modbus documentation,
although most vendors today have developed schemes for storing these
numbers. The Modbus specification also does not address a way to store
or send characters like “a”, “-” or “X”. For this reason, transfer of complete
tank names using Modbus is not possible unless the tank name is made up
of all numbers.
Function codes
Function code 01: Read coil status
Reads the ON/OFF status of discrete outputs ((0)xxxx references, coils)
in the slave. Broadcast is not supported. The maximum number of coils
that can be requested in one request is 7D0 (2000DEC).
Query The query message specifies the starting coil and quantity of coils to be
read:
Response The coil status in the response message is packed as one coil per bit of
the data field. Status is indicated as: 1 = ON, 0 = OFF. All coils are
default OFF.
Query The query message specifies the starting input and quantity of inputs to
be read:
Response The input status in the response message is packed as one input per bit
of the data field. Status is indicated as: 1 = ON, 0 = OFF. All status inputs
are default OFF.
Query The query message specifies the starting register and quantity of
registers to be read:
Response The register data in the response message is packed as two bytes per
register, with the binary contents right-justified within each byte:
Query The query message specifies the starting register and quantity of
registers to be read:
Response The register data in the response message is packed as two bytes per
register, with the binary contents right-justified within each byte:
Response The normal response is an echo of the query, returned after the coil state
has been forced:
Response The normal response is an echo of the query, returned after the register
contents have been preset:
Query
Slave Function 08 Sub- Data CRC check
address function
Slave Function 15 Coil Number of Byte count Force data CRC check
address (0FHEX) address coils
Response The normal response returns the slave address, function code, starting
address, and quantity of coils forced:
Response The normal response returns the slave address, function code, starting
address, and quantity of registers preset:
The exception response message has two fields that differentiate it from
a normal response:
The Function code returned in an error is the function code of the received
function with the high order bit of the function set to “1”.
Data field
In a normal response, the slave may return any information that was
requested in the query. In an exception response, the slave returns an
exception code in the data field. This code defines the slave's condition
that caused the exception.
Enraf implementation
All Modbus memory addresses in this chapter are in hexadecimal format.
Gauge commands via Coil commands are available in CIU Prime and
CIU Plus.
Firmware version must be 1.100 or higher.
The sequence how the tanks are ordered in the Modbus memory map
defines the address sequence where the tank gauge command must be
given. In the table below a Relative address is given from which the actual
coil address can be calculated by using formula:
4 R/W Density dip Writing “1” will result in Density dip command
5 R/W Water dip Writing “1” will result in Water dip command
6 R/W Combined dip Writing “1” will result in Combined (water/density) dip
command
0000 - 0009 CIU status area In this area the status of the CIU is
represented
000A 1bit Gauge status In this area the status of the tank is
: discrete area represented
depending input
number of area Gauge level In this area the status of the gauge level
tanks in alarms area alarms is represented
modbus
memory External alarms In this area the status of the external
map area alarms is represented
Statuses via discrete inputs are available in CIU Prime and CIU Plus.
Firmware version must be 1.100 or higher.
CIU status
The CIU status can be read.
Gauge status
The Gauge status can be read. The total number of tanks and the
sequence how the tanks are ordered in the Modbus memory map defines
the address sequence where the status can be read. In the tables below a
relative address is given from which the actual coil address can be
calculated by using a formula. The discrete input address is calculated
with formula:
3 R External contact not “1” indicates ext. contacts not available in gauge.
available
16 bit area
In the 16 bit registers space both the holding registers and the input
registers are combined in one address space.
0000.. User tank data In this area the user can request for
..1F3F user area tank data.
data
251C.. area User CIU data General data of CIU Prime/Plus
..2647 area
A selection can be made which data must be presented in the user defined
tankdata area. This because of the lot of information which can be retrieved.
See the related Instruction manual CIU Prime or CIU Plus for a list of
selectable data.
One tank data reply packet is selected which is used for all tanks available to
the Modbus host.
The sequence how the tanks are organized in the user defined Modbus map is
programmable.
There are two methods possible to organize the user defined Modbus memory
map:
1. Tank oriented.
Data in the Modbus memory map is grouped per tank.
Start address of memory map is programmable. Default start address is 0000.
The startaddress-interval between the tankrecords is programmable.
2. Data oriented.
Data in the Modbus memory map is grouped per selected entity.
Start address of memory map is programmable. Default start address is 0000.
2520 R/W 521 Years (yyyy) Prime/Plus CIU year (max 16383)
2521 R/W 522 Months (mm) Prime/Plus CIU month (max 12)
2522 R/W 523 Days (dd) Prime/Plus CIU day (max 31)
2523 R/W 524 Hours (hh) Prime/Plus CIU hour (max 23)
2524 R/W 525 Minutes (mm) Prime/Plus CIU minute (max 59)
2525 R/W 526 Seconds (ss) Prime/Plus CIU second (max 59)
Overwrite Observed density and Observed temperature (direct overwrite on CIU Plus only).
To overwrite the Observed density (800 kg/m3) including related observed temperature (15 C) for
tank 2, registers 000E and 000F must be overwritten by using function code 06 or function code 16.
The data will be used for internal calculations provided that it is not automatically measured.
29 10 00 0E 00 02 04 1F 40 04 7E +CRC
in which
29 RTU address (41DEC)
10 Function code (16 DEC)
00 0E Start address (15DEC)
00 02 Number of registers (2DEC)
04 Byte Count (4 DEC)
1F 40 Observed density [8000 DEC = (800 * 10) + 0]
04 7E Observed temperature [1150 DEC = (15 * 10) + 1000]
CRC
29 10 25 20 00 07 0E 07 CF 00 09 00 18 00 0E 00 03 00 17 00 01 +CRC
in which
29 RTU address (41DEC)
10 Function code (16 DEC)
25 20 Start address (9504DEC)
00 07 Number of registers (7DEC)
0E Byte Count (14 DEC)
07 CF Year (1999 DEC)
00 09 Month (9 DEC)
00 18 Day (24 DEC)
00 0E Hour (14 DEC)
00 03 Minutes (3 DEC)
00 17 Seconds (23 DEC)
00 01 DayLightSaving on (1 DEC)
CRC
After downloading the Date&Time the received data will be used to set the internal CIU clock as
required.
The operation can be verified by reading the same registers and interpret the contents.
Gauge status
address Description Tankname
000A Gauge measuring level status 1
000B Gauge failure status 1
000C Gauge measuring level status 2
000D Gauge failure status 2
000E Gauge measuring level status 3
000F Gauge failure status 3