4modbus message framing – KROHNE OPTISONIC V6 Modbus User Manual
Page 6
2011-07-19
OPTISONIC_V6_Modbus_6.doc
6/29
K
R
O
H
N
E
C
T
P
ro
d
u
c
ts
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
‘:’
2 characters
2 characters
N*2
characters
LRC
2 characters
CR-LF
RTU
Mode
3.5
characters
silent interval
8 bits
8 bits
N*8 bits
CRC
16 bits
3.5 character
silent interval
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.