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
most appropriate action – either to repeat the original message, to try and diagnose
what has happened to the slave, to set alarms or to take whatever action is most
appropriate.
Leave a comment
Your email address will not be published. Required fields are marked *