KROHNE OPTISONIC-V6 User Manual

OPTISONIC V6
Modbus manual
KROHNE CT Products
Protocol description
&
set-up
KROHNE takes great care to make sure the information in this document is correct, accurate and as complete as deemed necessary. Despite this, KROHNE rejects any responsibility for the consequences of missing or incorrect information in this manual.
Responsibility for setting up and operating a Modbus communication link, as described in this manual, rests solely with parties involved in the implementation and operation of such a data communication link.
It is KROHNE policy to maintain and update this document as necessary, however this is not a controlled document. Owners of this document can not claim that KROHNE is responsible for replacing this version of this document in case an updated version becomes available.
Nothing from this document may be copied or reproduced without the written permission of KROHNE Altometer
2011-07-19 OPTISONIC_V6_Modbus_6.doc 1/29
TABLE OF CONTENTS
1 INTRODUCTION ......................................................................................................................................3
2 PHYSICAL COMMUNICATION LAYER...................................................................................................4
3 SERIAL TRANSMISSION FORMAT ........................................................................................................5
3.1 ASCII mode ....................................................................................................................................5
3.2 RTU mode ......................................................................................................................................5
4 MODBUS MESSAGE FRAMING .............................................................................................................6
4.1 The Address Field (Device Address) .............................................................................................6
4.2 The Function Field .........................................................................................................................6
4.3 The Data Field................................................................................................................................6
4.4 Error Checking Methods ................................................................................................................7
4.4.1 Error check in ASCII mode transmission .............................................................................7
4.4.2 Error check in RTU mode transmission ...............................................................................7
4.5 Transmission gaps .........................................................................................................................7
4.5.1 ASCII mode..........................................................................................................................7
4.5.2 RTU mode............................................................................................................................7
4.6 Response time out .........................................................................................................................7
5 SUPPORTED FUNCTIONS .....................................................................................................................8
5.1 Function 01: READ COILS.............................................................................................................8
5.2 Function 02: READ DISCRETE INPUTS .......................................................................................8
5.3 Function 03: READ HOLDING REGISTERS .................................................................................9
5.4 Function 04: READ INPUT REGISTERS.......................................................................................9
5.5 Function 05: WRITE SINGLE COIL ...............................................................................................9
5.6 Function 06: WRITE SINGLE HOLDING REGISTER....................................................................9
5.7 Function 8: DIAGNOSTICS..........................................................................................................10
5.8 Function 15: WRITE MULTIPLE COILS ......................................................................................10
5.9 Function 16: WRITE MULTIPLE HOLDING REGISTERS...........................................................10
5.10 Exception Responses ..................................................................................................................11
6 HANDLING OF LARGE DATA TYPES ..................................................................................................12
6.1 Integer (16 bit), Transmit Sequence ............................................................................................12
6.2 Long integer (32 bit), Transmit Sequence....................................................................................13
6.3 Single precision floating-point (32 bit), Transmit Sequence ........................................................13
6.4 Double precision floating-point (64 bit), Transmit Sequence .......................................................13
6.5 Long long (64 bit integer), Transmit Sequence............................................................................14
6.6 Maximum number requested items..............................................................................................14
7 DEFAULT SETTINGS ............................................................................................................................15
8 MODBUS REGISTER MAPPING...........................................................................................................16
8.1 Input Registers (read-only): Integer (16-bit); address range 3000-3499 .....................................16
8.2 Holding Registers (read/write): Integer (16-bit); address range 3500-3999 ................................17
8.3 Input Registers (read-only): Long integer (32-bit); address range 5000-5499 ............................17
8.4 Holding Registers (read/write): Long integer (32-bit), address range 5500-5999 .......................20
8.5 Input Registers (read-only): Double (64-bit floating-point), address range 6000-6499 ...............21
8.6 Holding Registers (read/write): Double (64-bit floating-point), address range 6500-6999 ..........21
8.7 Input Registers (read-only): Float (32-bit floating-point), address range 7000-7499...................22
8.8 Holding Registers (read/write): Float (32-bit) floating-point, address range 7500-7999..............25
8.9 Input Registers (read-only): Long long (64-bit integer), address range 8000-8499.....................28
8.10 Holding Registers (read/write): Long long (64-bit integer), address range 8500-8999................29
KROHNE CT Products
2011-07-19 OPTISONIC_V6_Modbus_6.doc 2/29
1 INTRODUCTION
Scope
This manual describes how to use the Modbus protocol with the OPTISONIC V6 gas flow meter.
Introduction to Modbus
Modbus communication is based on the master-slave principle. Only the master can initiate transactions (requests), and only the addressed device (slave) responds. The master can also send a broadcast message (“message to all”); none of the slaves will respond to such a message.
The OPTISONIC V6 flow meter always acts as a Modbus compatible slave when communicating with host systems. Slaves are identified by means of a “device address”. Check the documentation to find the preset device address of your OPTISONIC V6 flow meter. In case necessary, the address can be reprogrammed. Contact the manufacturer for information about the procedures and tools that are needed for reprogramming the device address.
The Modbus protocol defines a message structure that Modbus enabled controllers will recognise and use, regardless of the type of network over which they communicate. It describes:
the process a controller uses to request access to other devices,
how to respond to requests from the other devices, and
how errors will be detected and reported.
The Modbus request consists of:
an address,
a function code defining the requested action,
data (if necessary for the requested function), and
an error check for testing the integrity of the message.
The slave’s response contains:
the slave address,
data conform the request type, and
an error check.
If the data integrity test fails, no response is sent back. If a request cannot be processed an exception message is returned.
KROHNE CT Products
2011-07-19 OPTISONIC_V6_Modbus_6.doc 3/29
2 PHYSICAL COMMUNICATION LAYER
The Modbus over serial line protocol is a master-slave protocol. The physical layer can be half-duplex or full­duplex.
In case of the OPTISONIC V6 the physical layer is a half-duplex (two-wire) connection according to RS 485 specifications.
The end of a RS485 line has to be terminated by means of a resistor. This terminating resistor is included in the line driving circuit in the OPTISONIC V6.
Multiple OPTISONIC V6 meters may be connected to the same RS 485 line. In this case only the terminating resistor in the OPTISONIC V6 at the end of the line should be connected. The terminating resistors in the other OPTISONIC V6 meters on the line should be disconnected by means of the switch on the RS 485 driver printed circuit board. Default this switch is set to connect the line terminating resistor.
Because of the half-duplex operation, the RS 485 communication circuit in the OPTISONIC V6 is normally always in data receiving mode. Only in case it is requested to send it will automatically switch to data transmit mode for the time needed.
KROHNE CT Products
2011-07-19 OPTISONIC_V6_Modbus_6.doc 4/29
3 SERIAL TRANSMISSION FORMAT
Two transmission modes are defined for a Modbus data communication link:
Modbus ASCII
Modbus RTU.
Both transmission modes are supported, the user can select the desired mode along with the serial communication parameters (baud rate, parity).
The default configuration of the OPTISONIC V6 is Modbus RTU communication mode with “standard” Modbus settings.
Check chapter 7 for a list of programmable parameters and the default settings of these parameters. Except for the device addresses all these parameters must be the same for all controllers in the network.
3.1 ASCII mode
In the Modbus message each byte of data is coded as 2 ASCII characters; one to represent the upper 4 bits and another to represent the lower 4 bits. Each group of 4 bits is represented by a hexadecimal number, transmitted as an ASCII character from the range 0-9, A-F.
Standard serial communication parameters: Start bits: 1 Data bits: 7 Parity: odd/even/none Stop bits: 1 stop bit if parity is used, or
2 stop bits if no parity is used.
Error check field: Longitudinal Redundancy Check (LRC).
An advantage of ASCII mode is that it allows for a time interval up to 1 second between characters without causing a timeout. A disadvantage of ASCII mode is the larger message length.
KROHNE CT Products
3.2 RTU mode
Each byte of data is represented in the message by an equivalent number of bits (8).
The number of bits transmitted in the process of communicating one byte of information is sometimes also referred to as a “character”. Note that this is not the same as an ASCII character.
Default serial communication parameters: Baud rate: 19200 Data bits: 8 Parity: even Stop bits: 1 Error check field: Cyclic Redundancy Check (CRC).
2011-07-19 OPTISONIC_V6_Modbus_6.doc 5/29
4 MODBUS MESSAGE FRAMING
ASCII mode
In ASCII mode a message starts with a colon character (:) and ends with a carriage return-linefeed.
Intervals up to one second can elapse between characters within the message. If the interval is longer, a timeout error occurs and the message is rejected.
RTU mode
In RTU mode a message starts with a silent time interval equivalent to at least 3.5 characters. The entire message frame must be transmitted as a continuous stream. If a silent interval of more than 3.5 character times occurs before completion of the frame, the receiving device flushes the incoming message and assumes that the next byte will be the address field for the new message.
Example of a typical message frame:
Mode START ADDRESS FUNCTION DATA CHECKSUM END ASCII Mode
RTU
Mode
‘:’ 2 characters 2 characters
3.5
characters
silent interval
8 bits 8 bits N*8 bits
N*2
characters
LRC
2 characters
CRC
16 bits
CR-LF
3.5 character silent interval
KROHNE CT Products
4.1 The Address Field (Device Address)
The address field of a message frame contains: ASCII mode: 2 characters RTU mode: 8 bits
Valid slave addresses are 1 to 247. Address 0 is used for a broadcast to address all slaves.
4.2 The Function Field
The function field of a message frame contains: ASCII mode: 2 characters RTU mode: 8 bits
Valid function codes lie in a range of 1 to 127.
The function code tells the slave which kind of action to perform.
The supported functions are listed in chapter 5.
A slave response always contains the function code of the request. If a function is not applicable, the slave sends an exception response. An exception is indicated by a returned function code with bit 8 (most significant bit) set.
4.3 The Data Field
The data field contains 8 bit values (bytes) in the range of 0 to FF hexadecimal.
In ASCII mode each 8 bit value is represented by 2 ASCII characters.
The data field of messages contains information which both master and slave use to perform an action. This includes the register address, quantity of registers, and the necessary data.
2011-07-19 OPTISONIC_V6_Modbus_6.doc 6/29
4.4 Error Checking Methods
Two error checking methods are defined for the Modbus protocol:
Optional: an additional bit (parity bit) is appended to each character (or byte) for detecting errors
during the transmission of individual characters (or bytes)
Obligatory: two bytes (or characters) are appended to the message for detecting errors during the
transmission of the message
As an even number of bit errors in one character (or byte) will not be detected using a parity bit, the second method is used to check the contents of the entire message.
Both character check and message check are generated in the transmitting device and appended to the message before transmission. The slave checks each character and the entire message frame during receipt.
The contents of the error checking field for the entire message depend on the transmission mode.
4.4.1 Error check in ASCII mode transmission
For detecting errors in the entire message the error-checking field contains two ASCII characters. The error check characters are the result of a Longitudinal Redundancy Check (LRC) calculation. This is performed on the message contents with exception of the beginning colon, the carriage return and line feed characters. The LRC characters are appended to the message as the last field preceding the CR-LF characters.
KROHNE CT Products
4.4.2 Error check in RTU mode transmission
For detecting errors in the entire message the error-checking field contains a 16-bit value implemented as two bytes. The error check value is the result of a Cyclic Redundancy Check (CRC) calculation performed on the message contents. The CRC field is appended to the message as the last field.
4.5 Transmission gaps
Gaps that exceed a specific value during the transmission of a message will be qualified as a transmission error.
4.5.1 ASCII mode
In ASCII mode the maximum time between 2 characters is one second. If a longer interval occurs, the message will be ignored and the search for a starting character (colon) is resumed.
4.5.2 RTU mode
In RTU mode the entire message frame must be transmitted as a continuous stream. If a silent interval of more than 3.5 character times occurs before completion of the frame, the receiving device ignores the message and assumes the next byte will be the device-address field of a new message.
4.6 Response time out
The master device has a predetermined time-out interval before aborting a transaction.
This interval shall be set long enough for any slave to respond normally.
2011-07-19 OPTISONIC_V6_Modbus_6.doc 7/29
5 SUPPORTED FUNCTIONS
A number of functions is available to perform operations on variables in the slave.
An operation can be a “read” operation to obtain the value of a variable or a “write” operation to assign a value to a variable. Variables are identified by means of their register number (address).
Typically in a Modbus slave, data can be stored in multiple areas that can be seen as different memories:
Discrete Inputs: data from logical (also called binary, Boolean, or ON/OFF) inputs. By nature the data
in this area is “read-only”: the master has only access to read this data.
Coils: logical (also called binary, Boolean, or ON/OFF) outputs. The master device may read the
current state of an output, but may also set or change the state of an output.
Input Registers: data, for example originating from electrical inputs of the slave or results from
calculations in the slave, can be stored in “input registers”. By nature the data in this area is “read­only”: the master has only access to read this data.
Holding Registers: the master has access to this area to read the data but as well to set or change the
value of data (write).
As these register groups are located in apparently different memories, the addresses may overlap: for example, an input register having address 100 can exist and at the same time a holding register having address 100. These are not the same: which one will be selected for an operation is implied from the function code, referring to an input register or to a holding register, for example.
The OPTISONIC V6 does not use Discrete Inputs or Coils, but only Input Registers and Holding Registers.
Variables are grouped according to data type and dependant of being input registers (read-only data) or being holding registers (read/write data). An address range is assigned to each variable type, subdivided in input registers (read-only) and holding registers (read/write).
The OPTISONIC V6’s address ranges of Input Registers and Holding Registers do not overlap. Accessing a specific register address is therefore unambiguous. The functions “read register” and “read input” could both be used to effectively access the same register/address. However, in this application, functions shall still be used consistent with the type of memory they are intended to be used for.
In the master and the slave register addresses are referenced (counted) starting from 1. However, the address range used in the message during in the transmission starts from 0. As an example, when referencing address 4001, the address actually present in the message will be 4000.
On an application level the user will not notice this, as during the coding and decoding of the message this offset of 1 will be taken into account. However, when the message – as it is transmitted – is analyzed and checked one has to be aware of this offset.
When functions which do not support broadcast requests, are accessed with a broadcast address, the request will be ignored.
KROHNE CT Products
5.1 Function 01: READ COILS
Function 01 reads the status of 1 to 2000 contiguous logical (Boolean or ON/OFF) variables.
This function is not used, as in this application Boolean (or logical) variables are not used as individual entities. Boolean variables are represented by means of specific bits packed in 32 bit data word (type “Long”).
5.2 Function 02: READ DISCRETE INPUTS
Function 02 reads the status of 1 to 2000 contiguous logical (Boolean or ON/OFF) variables.
This function is not used, as in this application Boolean (or logical) variables are not used as individual entities. Boolean or logical variables are represented by means of specific bits packed in 32 bit data word (type “Long”).
2011-07-19 OPTISONIC_V6_Modbus_6.doc 8/29
5.3 Function 03: READ HOLDING REGISTERS
Function 03 reads the contents of 1 to 125 contiguous holding registers in the slave.
The maximum number of registers at each request is limited to 125 16-bit registers: 125 integers, 62 long integers, 62 floats, 31 doubles or 31 long longs.
Request
The request message specifies the starting register and the quantity of registers to be read. Registers are addressed starting from zero. Registers 1-16 are addressed as 0-15.
Example
A request to read from slave device 17, registers 40108-40110 (decimal), or starting from 9CAC (hex):
Header
--
Slave
Address
11(h)
Function
03(h)
Starting address Number of data items
Hi
9C(h)
Low
AB(h)
Hi
00(h)
Low
03(h)
Error check
--
Trailer
--
Response:
--
Slave
address
11(h)
Function
03(h)
Byte
count
06(h)
(Reg.
40108
Hi)
02(h)
(Reg.
40108
Low)
2B(h)
(Reg.
40109
Hi)
00(h)
Data Header
(Reg.
40109
Low) 00(h)
(Reg.
40110
Hi)
00(h)
(Reg.
40110
Low)
64(h)
Error
check
--
Trailer
--
For each register the first byte contains the high order byte, the second the low order byte.
The contents of register 40108 are shown as the two byte values of 02 2B hex (555 decimal). The contents of register 40109 is 00 00 hex (0 decimal) and of register 40110 is 00 64 hex (100 decimal).
If the request is not applicable, an exception response will be sent. See chapter 5.10 for exception
responses.
5.4 Function 04: READ INPUT REGISTERS
Function 04 performs a “read” operation, similar to function 03. The difference is that function 04 addresses input registers (which are “read-only”), whereas function 03 addresses holding registers (which are “read/write”).
KROHNE CT Products
5.5 Function 05: WRITE SINGLE COIL
Function 05 writes the status of a logical (Boolean or ON/OFF) variable.
This function is not used, as in this application Boolean variables are not used as individual entities. Boolean variables are represented by means of specific bits packed in 32 bit data word (type “Long”).
5.6 Function 06: WRITE SINGLE HOLDING REGISTER
Function 06 presets a value into a single holding register.
When the address is a broadcast, all slaves will process the request.
Request
The request specifies the register reference to be written. Registers are addressed starting from zero.
2011-07-19 OPTISONIC_V6_Modbus_6.doc 9/29
Loading...
+ 20 hidden pages