S600 Modbus Communication Protocol Guide
S600 Modbus Communication Protocol Guide
DOC
SYSTEM OVERVIEW
BASE DOCUMENTATION
MODBUS COMMUNICATIONS
Proprietary Statement
This document, submitted in confidence contains proprietary information which shall not be reproduced or
transferred to others for the purpose of manufacture, tender or any other purpose without prior written
permission of Daniel Europe Limited.
Copyright (C) Daniel Europe 2002
TABLE OF CONTENTS
1. INTRODUCTION 3
3. NETWORK INTERFACE 3
4. MODBUS 3
4.1 Configuration 3
4.2 Master 3
4.3 Slave 3
5. RTU/ASCII PROTOCOL 3
8. REGISTER FORMATS 3
8.1 Background 3
8.2 Addresses per Item 3
1. INTRODUCTION
This document describes the Modbus communications protocol on the FloBoss S600
flow computer.
TCP/IP stream socket support is provided for master and slave links.
If the unit is the slave on the link it creates a server socket and listens for clients to
connect. The TCP/IP address of the slave link is the TCP/IP address of the flow
computer.
If the unit is the master it acts as a client and attempts to connect to a remote server
machine. The TCP/IP address of the slave which the master must communicate with
is specified when the link is configured.
The data transfer within the Modbus part of the protocol is standard Modbus. The
only significant difference is that the Modbus CRC is not use. Instead the CRC used
with the TCP/IP protocol is used.
2.3 Serial
7 (ASCII), 8 (RTU)
Note that 7 bit must be used for Modbus ASCII and 8 bit must be used for Modbus
RTU
1, 2
2.3.4 Parity
Reserved for the Config 600 interface. Actually a Modbus slave link.
3. NETWORK INTERFACE
The S600 includes a single 10Mbit/s Ethernet interface and the system provides a full
TCP/IP stack implementation on this interface.
• Telnet
• FTP
4. MODBUS
The Config 600 interface to the flow computer is via Modbus. In this case the link
uses the special function code 65, with specially defined (S600 specific) sub- functions
to provide file transfer, system edit commands and other specialised functionality.
The flow computer is the slave on this link.
4.1 Configuration
The system supports up to ten communication links. These links may all be
individually configured if required or may share common parameters or configuration.
The link configuration; which port or socket to use, master or slave, RTU or Modbus.
This information is entered using Config 600 when the link is assigned. It may be
modified later if required.
The map configuration; assignment of database points and fields to Modbus coils,
inputs and registers. This is accomplished using a text file that is initially created
using the Config 600’s map builder utilities. The map may be subsequently edited as
required.
4.2 Master
4.3 Slave
In slave mode the unit waits for polls from an external master. It responds to polls as
requested. Several slaves may be configured if required.
The slave address is configurable per link so a single flow computer may have several
slave addresses if required.
5. RTU/ASCII PROTOCOL
RTU Modbus and ACSII Modbus are fully supported. A single configuration switch
selects one or other. Other communication parameters are independent of the
ASCII/RTU switch.
In RTU mode, the link must be configured for 8 data bits. No message header or
trailers are included. The checksum is the 16-bit CRC specified in the Gould Modbus
specification.
In ASCII mode, the link should normally be configured for 7 data bits, however 8 is
also supported by the S600. The message starts with the ASCII Modbus start
character ‘:’. The checksum is the 8-bit LRC defined in the Gould Modbus
specification. The message is terminated with the ASCII Modbus trailer characters
CR then LF.
Important note:
The unit is not strictly RTU compliant. Small inter-character gaps on received
messages will not cause the unit to think that a new message has arrived.
The message formats are detailed below. Note that these exclude the message header
(ASCII only), the CRC/LRC and the message trailer (ASCII only) as these are specific
to the data transfer mode.
Function Code 01
Reads output coils (e.g. 00001 – 09999), up to 2040 coils can be read per poll in non-
extended mode.
Poll Format
Address 1 byte
Function 1 byte
Start Coil 2 bytes
Num Coils 2 bytes
Response Format
Address 1 byte
Function 1 byte
Byte count (see note) 1 or 2 bytes
Data byte 1 1 byte(coils 0..7)
Data byte 2 1 byte(coils 8..15)
..
Data byte N 1 byte(coils ….)
Note:
Byte count may be: 8 bit byte count
16 bit byte count
Function Code 02
Reads input coils (e.g. 10001 – 19999), up to 2040 coils can be read per poll in non-
extended mode.
Poll Format
Address 1 byte
Function 1 byte
Start Input 2 bytes
Num Inputs 2 bytes
Response Format
Address 1 byte
Function 1 byte
Byte count (see note) 1 or 2 bytes
Data byte 1 1 byte(inputs 0..7)
Data byte 2 1 byte(inputs 8..15)
..
Data byte N 1 byte(inputs ….)
Poll Format
Address 1 byte
Function 1 byte
Start Item 2 bytes
Num Items 2 bytes
Response Format
Address 1 byte
Function 1 byte
Length (see note) 1 or 2 bytes
Data item 1 2, 4 or 8 bytes
Data item 2 2, 4 or 8 bytes
..
Data item N 2, 4 or 8 bytes
Function Code 04
Reads input registers (e.g. 30001 - 39999). Data can be configured at every address
Poll Format
Address 1 byte
Function 1 byte
Start Item 2 bytes
Num Items 2 bytes
Response Format
Address 1 byte
Function 1 byte
Length (see note) 1 or 2 bytes
Data item 1 2, 4 or 8 bytes
Data item 2 2, 4 or 8 bytes
..
Data item N 2, 4 or 8 bytes
Function Code 05
Writes a single coil, either on (1) or off (0). Any valid coil address can be written to
(e.g. 00001 - 09999)
Poll Format
Address 1 byte
Function 1 byte
Coil Number 2 bytes
Coil Value 2 bytes
Response Format
Address 1 byte
Function 1 byte
Coil Number 2 bytes
Coil Value 2 bytes
Writes a value to a single holding register in standard Modicon Modbus format. Any
valid holding register address can be written to (e.g. 40001 - 49999)
Poll Format
Address 1 byte
Function 1 byte
Item Number 2 bytes
Value 2 bytes
Response Format
Address 1 byte
Function 1 byte
Item Number 2 bytes
Value 2 bytes
Note: The write single register function is only applicable to simple 16-bit
registers. The float and double formats are not supported.
Function Code 08
Performs a loopback test. There are no variable parameters available on this function
code, if successful a loopback test will return the poll received.
Poll Format
Address 1 byte
Function 1 byte
Value 1 2 bytes
Value 2 2 bytes
Response Format
Address 1 byte
Function 1 byte
Value 1 2 bytes
Value 2 2 bytes
Function Code 15
Writes multiple coils on (1) or off (0). Data should be entered as a string of up to 8
characters (1’s and 0’s), the RHS entry representing the LSB. Data can be written to
any valid coil address (e.g. 00001 - 09999)
Poll Format
Address 1 byte
Function 1 byte
Start Coil 2 bytes
Num Coils 2 bytes
Byte count (See note) 1 or 2 bytes
Data byte 1 1 byte(Coils 0..7)
Data byte 1 1 byte(Coils 8..15)
…
Data byte N 1 byte(Coils …)
Poll Format
Address 1 byte
Function 1 byte
Start Item 2 bytes
Num Items 2 bytes
Byte count (See note) 1 or 2 bytes
Data item 1 2, 4 or 8 bytes
Data item 2 2, 4 or 8 bytes
..
Data item N 2, 4 or 8 bytes
Daniel user defined function code, used to read multiple holding registers in IEEE
single precision format. The valid address range is 0 - 65535, data can be configured at
every address.
NOTE:
The Config 600 interface to the flow computer is via Modbus. In this case the link
uses the special function code 65, with specially defined (S600 specific) sub- functions
to provide file transfer, system edit commands and other specialised functionality.
The flow computer is the slave on this link.
Daniel user defined function code, used to write multiple holding registers in IEEE
single precision format. The valid address range is 0 - 65535, data can be configured at
every address.
Daniel user defined function code, used to read multiple holding registers in IEEE
double precision format. The valid address range is 0 - 65535, data can be configured
at every address.
Daniel user defined function code, used to write multiple holding registers in IEEE
double precision format. The valid address range is 0 - 65535, data can be configured
at every address.
Using standard Modbus, all variable length messages include a 8-bit byte count field
which allows the receiver to determine the amount of data in the message.
In some applications, the use of this field is not the actual byte count but the number
of data items in the message. This variation only applies to register messages.
Daniel has added a further extension to this, primarily for communication with the
DMS supervisory; the field may be extended to a 16-bit value. This simply allows
more data to be transferred on the link. Note that this functionality is no longer
Modbus
The message contains a single byte, which determines the number of data bytes in the
message.
The message contains a single byte, which determines the number of data items in the
message.
The message contains a pair of bytes, which determines the number of data bytes in
the message.
The message contains a pair of bytes, which determines the number of data items in
the message.
8. REGISTER FORMATS
8.1 Background
The Gould Modicon Modbus Protocol Reference Guide does not specify how numbers
greater than 16 bits (eg 32-bit integers and single and double precision real numbers)
should be transferred.
The Modbus protocol has 16-bit elements (called registers), and as such is only
suitable for transferring 16-bit integer data. Since no standard exists,
Daniels have developed the following formats suitable for transferring numerial data
to third parties, and offers these as a standard solution.
[FORMAT FLOAT]
Holding registers as IEEE format single precision floating point numbers, MSB first.
For each point required, one address is requested in the modbus message, 4 bytes are
returned, data is configurable at every address (e.g. 40001 - 49999)
[FORMAT ROSEMOUNT]
Holding registers as IEEE format single precision floating point numbers, LSB first
(used on Rosemount DCS system). For each point required, two addresses are
requested in the modbus message, 4 bytes are returned, data is configurable at every
other address (e.g. 40001, 40003 ...... 49999)
[FORMAT DOUBLE]
Holding registers as IEEE format double precision floating point numbers. For each
point required, one address is requested in the modbus message 8 bytes are returned,
data is configurable at every address.(e.g. 40001 - 49999)
Holding registers as IEEE format single precision numbers, MSB first. For each point
required, two addresses are requested in the modbus message, 4 bytes are returned.
Data is configurable at alternate addresses. (e.g. 40001, 40003 ..... 49999)
Holding registers as IEEE format double precision numbers, MSB first. For each point
required, four addresses are requested in the modbus message, 8 bytes are returned.
Data is configurable at every fourth addresses. (e.g. 40001, 40005 ..... 49997)
Holding registers as 16 bit SIGNED integers, range -32767 (Hex 8001) to 32767
(Hex 7FFF). Data can be configured at every address (e.g. 40001 - 49999)
Holding registers as SIGNED long integers. For each point required one is requested
and two registers (4 bytes) are returned in the modbus message. Data can be
configured at every address (e.g. 40001, 40002, …. 49999).
Holding registers as integers, scaled between 0 and nnnn. In master mode the value
returned will be displayed in terms of the selected scaling. For example 500 would
represent 50% on 999 scaling or 5% on 9999 scaling. Data can be configured at every
address (e.g. 40001 - 49999)
Scaled 16 bit integer between 0....9999 (or any other integer combination) where each
real is scaled within this range based upon preconfigured zero and full scales.
i.e.
e.g. A flowrate of 300 m3 /hr has a zero scale of 0m3 /hr and a full scale of 1000 m3 /hr
Thus the supervisory would send 3000 to represent the flowrate 300 m3 /hr if integer
range was 0…9999.
Integer holding registers (16 bits, valid data 0 - 65535) using Modicon Modbus
formatting. Any valid holding register can be written to (e.g. 40001 - 49999)
Holding registers as UNSIGNED LONG integers, negative numbers are not allowed.
Data can be configured at every address (e.g. 40001 - 49999)
The Enron Modbus protocol has been implemented as part of the Modbus slave
application. The design is based on:
Detailed below are the data areas defined in the Enron Modbus specification. The
S600 Modbus map builder will generate a map, which corresponds to this format.
The settings may be changed when the map is generated or by editing the Modbus
configuration file but this is not recommended.
9.1.1 AddressDescription
9.1.2 AddressDescription
9.1.3 AddressDescription
The Enron implementation provides a special set of registers and coils used to allow
transfer of alarm and event log data to a supervisory computer.
A coil write with the data value set, to this address will clear the event log.
A coil write with the data value clear, to this address will acknowledge the event log.
The normal base address for this value is 7001. It will be returned as a floating point
value.
A register read from this address will return the number of events available for
collection.
The normal base address for this value is 7002. It will be returned as a floating point
value.
A register read from this address will return the number of alarms available for
collection.
The normal base address for this value is 32. Data will be returned as a series of
registers as described below.
Poll Format
Function 31 byte
Response Format
Function 31 byte
20 bytes total
Bitmap
Bit 2 - Full scale Set when the full scale value of an analog
is changed
Bit 8 - Spare
Bit 14 - Rate of change limit Set when the ROC limit is changed
Bit 15 - Spare
Bit 14 - Rate of change limit Set when the ROC alarm is set/clr
Bit 15 - Set Reset Alarm 1 for alarm set, 0 for alarm clear
Data Point id
This is a unique id number which identifies the data point in the S600 database.
Time stamp
This floating point number represents the time associated with the alarm or event, the
value is:
Date stamp
This floating point number represents the date associated with the alarm or event, the
value is:
For event/change messages these are old and new value (i.e. from/to). For alarm
messages, the current value is in item five and the alarm limit is in item six.
Enron defines a pair of registers for reading a pair of reports logs from the flow
computer. The S600 supports this functionality with a number of enhancements:
2 Maint On demand
3 Batch On demand
Note that the configurable report periods may be selected from 1, 2, 3, 4, 6, 8 hourly,
daily, weekly or monthly.
Any combination of reports may be active in the S600 but even if gaps are present, the
indices remain the same.
The Enron specification states that all data will be presented in float format. The
S600 uses an improved method whereby there is a pair of polls for each log. One
(read configuration) returns the format of the data in the log, the other (read data)
return the data in the log, the items may be float or long int format.
To read the report log configuration data is it necessary to poll for Modbus registers at
one of the addresses in the Modbus log configuration area of the map.
This data is normally placed at register address 701 to 720. Each address corresponds
to a particular report period. The response defines the format of the report.
Poll Format
Function 31 byte
Response Format
Function 31 byte
Or totalise2 bytes
To read the actual report log data it is necessary to poll for Modbus registers in at one
of the addresses which corresponds to a report log.
This data is normally placed at register address 721..740. Each address corresponds
to a particular report period. The response contains the data from the report.
Poll Format
Function 31 byte
Response Format
Function 31 byte
All configuration files are ASCII text files which may be created manually if required.
However, the Config 600 program includes Modbus configuration file generators for
most common applications. These builders should always be used. The generated files
may then be edited manually if required.
There are two basic file types, master and slave. Both share many common features,
the slave file being a subset of the master configuration file.
The # symbol is used to indicate a comment. When a line is read, any characters
following a # symbol are ignored.
The overall layout of the configuration files depend on whether the file is for master or
slave use:
• Title
• Header Section
• Master Section
• Slave 1 Data
• Slave 2 Data
• …
• ..
• Slave N Data
• Title
• Header Section
• Slave 1 Data
This is simply a comment at the start of the file describing its function and version
history etc. It is ignored by the S600.
This block is mandatory and is used by both master and slave links. Four
commands are supported: All commands are enclosed in square brackets.
[TX BUFF SIZE <NNNN>]
These lines determine the size (in bytes) of the message transmit and receive
buffers. For normal Modbus operation they should both be set to 256 as this is
the maximum message size supported by Modbus. The valid range is 256-
65535.
[MSG LENGTH MODE <mode>]
This field determines how the message length part of the Modbus message is
handled. The basic Modbus specification defines this field as a single byte
which defines the number of bytes of data in the message. However many
implementations change this field to be an item count, i.e. the number of data
items in the message.
• BYTE_8
• BYTE_16
• ITEM_8
• ITEM_16
Note that if either of the 16-bit formats are used, the messages may be longer
than 256 bytes and the tx and rx buffer sizes should be adjusted accordingly.
[CHECKSUM <status>]
• TRUE
• FALSE
[CHECKSUM TRUE]
This section is only required for the master task. It defines the master’s poll loop
settings, the list of slave machines with which the master will communicate and a
series of poll to perform. Six commands are supported. All commands are
enclosed in square brackets.
[POLL DELAY <NNN>]
This specifies the delay between polls. The value is in system ticks (a tick is
1/60 of a second)
[LOOP DELAY <NNN>]
This specifies the delay at the end of the poll loop. The value is in system ticks
(a tick is 1/60 of a second)
[RETRY LIMIT <NNN>]
This specifies the number of retries the master should perform for a single
message before classing it as failed.
[TIMEOUT <NNN>]
This specified the amount of time the master will wait for a response from the
slave. The value is in seconds
[SLAVES <A> <B> <C> <D>]
This command is only used by the prover master link and specifies the
KPINT_ARRAY used to indicate the status of the link to each stream.
For each stream, the Modbus master task will update the KPINT_ARRAY
with:
Valve Description
0 Link OK
1 Link disabled
2 Telemetry failed
The message command is used to define a single message which the master
will perform. Any number of messages may be included. The master task will
perform them in the order they appear in the file. The trigger field is optional.
If it not present, the poll will always be performed. If it is present it defines a
KPINT object in the database which is used to control the poll. If the object is
non zero, the poll will be performed. It will not be performed if the object is
zero. The object will be set back to zero at the and of the poll loop.
• <n> is the database index for the KPINT object used to control the poll
# MASTER SECTION
[POLL DELAY 5]
[LOOP DELAY 5]
[RETRY LIMIT 3]
[TIMEOUT 5]
# LIST OF SLAVES
[SLAVES 1 ]
# NORMAL POLLS
For each slave which the master talks to, a slave data block is required. The block
start with the command:
[SLAVE ADDRESS <N>]
<N> may be from 1..255, i.e. a valid Modbus slave address value.
Following on from this statement will be the data map for the slave.
This section applies to both master and slave links. It defines the relationship
between Modbus addresses and S600 database points.
For the slave there will be a single map section. For the master there will be up to
10 slave sections, preceeded by the [SLAVE ADDRESS N] command.
The map is sub-divided into coil, input and register sections each of which form
independent blocks of data. Within each of these blocks there may be any number
of further sub-blocks.
[SECTION INPUTS]
The start of the Modbus Input data
[SECTION REGISTERS]
Within the coil section there may be any number of blocks of coil data. Each block
starts with the command:
The base address command will be followed by a list of data points each of which will
occupy successive coil addresses.
Within the input section there may be any number of blocks of coil data. Each block
starts with the command:
The base address command will be followed by a list of data points each of which will
occupy successive input addresses.
Within the register section there may be any number of blocks of register data. The
way in which data is packed into registers is controlled by three commands:
[FORMAT <format>]
Each block of register data may represent numeric data in a different format.
• SCALE
• SCALE 0 999
• SCALE 0 4096
• SCALE 0 9999
• FLOAT
• DOUBLE
• ENRON 16 BIT
• ENRON 32 BIT
• ENRON FLOAT
• ROSEMOUNT
• PHILLIPS FLOAT
• PHILLIPS DOUBLE
For 32-bit (4 byte) and 64-bit (8 byte) data it controls the way Modbus register
addressing is performed. It is closely related to the FORMAT command (or more
accurately the number of bytes per data item) and the number of addresses field
contained in the poll.
If the data is 32 bit, the addresses per item must be set to 1 or 2. If it is set to 1, the
number of addresses contained in the poll is the number of data items (ie 32 bit
entities) rather than the number of modbus registers. If the number of addresses per
item is 2, the number of addresses contained in the poll is the number of modbus
registers
If the data is 64 bit, the addresses per item must be set to 1 or 4. If it is set to 1, the
number of addresses contained in the poll is the number of data items (ie 64 bit
entities) rather than the number of modbus registers. If the number of addresses per
item is 4, the number of addresses contained in the poll is the number of modbus
registers.
ADDRESSES PER ITEM may be set to -1 for some special data formats. This
informs the modbus message building code to ignore the number of registers
requested. It is typically used for ENRON report data where the number of registers is
used to define the report number, but the number of registers to be transmitted is
actually determined by the report layout.
The addresses per item command will be followed by a list of data points each of
which will occup y successive register addresses.
All of the data which makes up a block is defined using a series of consecutive lines in
the configuration file which refer to objects in the S600 database.
Each line represents a point in the database. Any number of lines may be added to a
block. Each will refer to successive coils or inputs.
<OBJECT_BITNO> is the bit within the specified database point which will be
mapped to the coil or input.
See the exa mple slave configuration file for many examples of the format used.
All of the data which makes up a block is defined using a series of consecutive lines in
the configuration file whic h refer to objects in the S600 database.
Each line represents a point in the database. Any number of lines may be added to a
block. Each will refer to successive registers.
See the example slave configuration file for many examples of the format used.