Pareto principle: in 80% of your Modbus setups, Modbus will just work, and you hardly need to know anything about it, and you will spend 20% of your time making it work; in the remaining 20% of your Modbus setups, the implementations will have inconsistencies and will not work right off, and you will spend 80% of your time on those.
Get a Modbus program e.g. that
- can run on your PC (Windows, Linux, etc.).
- can run both Modbus Slave (Server) and Modbus Master (Client)
- displays the values sent and received "on-the-wire," preferably in hexadecimal
because it is far easier to debug one half of the Modbus implementations you are stuck with at a time. than debugging both at the same time.
Understand the Modbus protocol: navigate to
The Modbus Organization and read the Technical Documentation; it is fairly simple.
Always remember that in addresses such as
400001 or
300002, the prefix digits (
4 and
3) are
not part of the address.
Understand what each bit in a 16-bit integer means, signed and unsigned.
Know how to convert between hexadecimal and decimal representation of 8- and 16-bit values.
Always remember that for every Modbus implementation, Master or Slave, the numbering of the first address may be either 00000 or 00001; so if a Modbus Slave use a different first address convention than the Modbus Master you are using to make requests of that Modbus Slave, then you need to account for when you issue Modbus requests.
Bookmark this forum, and ask questions will complete information about the master, the slave, hexadecimal dumps, what you tried, what you expected, and whay you saw.
Bookmark this link.
Understand byte order (LSB- and MSB-first; Big-Endian and Litte-Endian).
All 16-bit registers
should be MSByte-first "on-the-wire" i.e. in the PDU (Protocol Data Unit; refer to the technical documentation).
All Modbus implementations
should correct that to its own architecture's internal byte order "behind the curtain" i.e. without you doing anything to the data being sent or received.
Never assume that any Modbus implementation
actually does what the previous two statements say it
should do; this is why the "displays the values sent ..." bullet point is so important.