Modbus data length


Thread Starter


We are implementing modbus on a new device which has limited memory resources. So the max data length it can send is 100. Is this a violation of modbus spec, as if a modbus master ask for a data length of 101 words of read register, our device will give a error. Is this a problem if when we try to get a modbus certification?
Just reply with a data value incorrect or address error. It is up to the master to know what should be requested so as long as it is in your spec I would not consider it a problem. On my products, there are some invalid addresses so it is sometiimes not possible to read a contiguous block anyhow...
Possibly a problem. One work around would be to group your modbus registers by function. (data, control, etc) and place gaps between. ie, 20 registers for data at offset 0. Then 20 more registers for control at offset +100, etc. Thus, there are never more than 100 contagious registers that are available to be read by the controller. Perhaps a bit of a hack, so use your best judgement.
Just return error code 2 (Illegal Data Address) anytime the master requests data from a register that is out of range for your device. This is valid operation. I hope this helps.

[email protected]

Automation Linse

This will be just a minor problem in the field - just make sure you CLEARLY document REPEATEDLY in your manual that max data read is 100 words. Most OPC servers now include MAX fields to limit reads/writes. Many "micro" devices limit it even farther (to 32 or less words), so it is the way of the future as people put Modbus into various PIC controllers with a few hundred bytes of RAM.

As for certs; again, if you clearly DOCUMENT this limit, then the U of Mich would only test that 100 works and 101 properly does NOT work.

See the "flow charts" in the latest specification to determine the CORRECT exception response to use. Last I talked to the lab, 99% of devices failing certification fail because of incorrect exception handling or bad behavior when seeing unexpected requests!! The flow charts make this very simple to select the correct code.

Best Regards
- Lynn A Linse,