Modbus.org has most of the information with respect to modbus. Modbus protocol has master/slave communication model. Master sends the queries to the slave to get a response. Masters have the capability to talk to individual slave or it can broadcast messages to all the slaves. Slave could be a Meter, Temperature reading device, etc.,
It supports two modes of communication one is ASCII and another is RTU mode. Modbus ASCII vs Modbus RTU to know the differences between ASCII and RTU Mode. Any communication to modbus slave for reading the registers should have the following components with it.
- Slave Id
- Function Code
- Data address of the first register to read
- Total number of register to be read or length to be read
- CRC check
Typically holding registers will hold the data which will be available in the register value between 40001-49999.
Lets take an example of reading a value from the register 110. Slave Id could be 1. The function code would be 3 for reading the holding register. So the offset value added would be with 40001+110 which would be 40111. Assuming we might need to 2 registers as the length. Maximum slave Id could be 247.
Important thing to understand while custom programming modbus devices is to ensure that modbus maps from the vendors are thoroughly read so that we can avoid overlaps.