Modbus message framing
Modbus messages must be structured (or 'framed') so that the different Modbus
components can detect the start, content structure and end point of a message. It also
allows any errors to be detected.
The framing used depends on the transmission mode chosen - ASCII or RTU.
ASCII message framing
In ASCII mode, messages start with a 'colon' (:), which in hex is '3A'. The message
end is shown by 'carriage return/line feed' (CRLF) or 'OD OA' in hex .
The allowable characters for all other fields are hexadecimal 0-9. A-F. Networked
components monitor the bus continuously for the 'colon' character and when one is
received, they decode the next field (the address field) to find out if the address is for
that slave. If the address is for another slave, then no action is taken, and the slave
returns to monitoring for the 'colon' character. If the field following the colon is the
address of the slave in question, then the slave continues to read the message and to
act on it's contents.

Intervals of up to one second can elapse between characters within the message, but
if an interval is greater than this, then the device assumes that an error has occurred.
If the delay occurs in the 'query' to a slave, then the addressed slave will discard the
message received up to that point and wait till the next message (marked by the colon
start character) is received.
RTU message framing
In RTU mode, the message begins with a gap in transmission of at least 3.5 character
periods. Network components monitor the bus continuously and when a 'silent' period
of more than 3.5 character periods is detected, the first character following the
transmission gap is translated to determine if it corresponds to the device's own
address.
The end of the transmitted message is marked by a further interval of at least 3.5
character periods duration. An new message can only begin after this interval.
The entire message field must be transmitted as a continuous stream. If an interval of
more than 1.5 character periods is detected during transmission of the message, then
the message is assumed to be incomplete and the device returns to waiting for the
next device address. The action taken on receipt of an incomplete message is as for
receipt of an incorrect message, and it is ignored.
If a new message begins within 3.5 characters periods of the end of the previous
frame, the device again ignores the message.
The message fields
The address field
Slave addresses may be in the range 1 to 247 with Modbus (1 to 255 with JBUS). A
slave is addressed by the master placing the relevant address in the address field of
the query message. When the slave sends its response, it places its own address in
the message field to indicate to the master that the correct slave is replying.
Address '0' is used for 'broadcast' messages. All suitable slaves read them, but do not
provide responses to such query messages.
The function field
Function codes may be in the range 1 - 255. though not all functions will be supported
by all devices. When a message is sent from a master to a slave, the function code
defines the action that is required from the addressed slave. Examples of action
requested by the various function codes include: read input status; read register
content; change a status within the slave; etc..
When the slave sends its response to the master, it will repeat the function code
received, to indicate that the slave has understood the query and acted accordingly. If
the query instruction could not be carried out by the slave, an 'exception response' is
generated and the function code and data fields are used to inform the master of the
reason for the exception.
The exception response is generated by returning the original function code from the
master, but with its most significant bit set to '1'. Further information regarding the
exception response is passed to the master via the data field of the response
message. This tells the master what kind of error occurred and allows it to take the
wechat/whatsapp:
Email: kongjiangauto@163.com
Copyright © 2009 - 2024 Cld , All Rights Reserved K-JIANG All rights reserved