Modbus exception code for data out of expected boundaries

V

Thread Starter

Volkan Celik

Hi,

I inspected the Modbus Application Protocol V1.1b document and saw that it doesn't suggest an Exception Code for data out of expected boundaries.

1) What should slave do if master wants to write (by using 0x06-Write Single Register) 1000 to slave's register which can accept only values between 0 and 100? I mean which exception code should slave return?

2) What should slave do if master wants to write (by using 0x10-Write Multiple Registers) 1000 and 10 to slave's two registers which can accept only values between 0 and 100? Does it return an Exception Code and doesn't write to any registers? Or does it write the value 10 and return an Exception Code? Or something else?
 
I
There is no exception code because the Modbus server should not treat these conditions as errors.

From the explanation of the ILLEGAL DATA VALUE exception code in the Modbus Application Protocol Specification V1.1b:

"A value contained in the query data field is not an allowable value for server (or slave). This indicates a fault in the structure of the remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register."

Note in particular "the MODBUS protocol is unaware of the significance of any particular value of any particular register".

If you want to follow the specification, then your server should accept writing of these out-of-bounds values without any error.

If you don't want to follow the specification, then return whatever exception you like.

(Of course, you should follow the specification.)
 
I've never seen a server (slave) *not* accept a properly formatted message. If you start returning exceptions, you really want to be sure how all the potential clients (masters) might react to this. Your users may end up being very unhappy if you cause them to spend time troubleshooting hardware faults because the client reports exceptions with a fault LED.

A more "conventional" way of dealing with this would be to just quietly ignore any attempts to write data that is out of range. To report the problem, designate one of the input or holding registers as a "status" register and set an error code number in the register which the client can read and react to.
 
Thread starter Similar threads Forum Replies Date
M Modbus 1
H Modbus 3
P Modbus 2
F Modbus 5
S Modbus 0
Top