Modbus
Reference documents
MODBUS APPLICATION PROTOCOL SPECIFICATION V1.1b
Needed information
Modbus TCP
| measure | modbus function | sampling_interval | target | slave | address | cast type |
|---|---|---|---|---|---|---|
| compartment1_temperature | read input registers | 10 | 192.168.0.100:502 | 1 | 2048 | uint16 |
| ... | ... | ... | ... | ... | ... | ... |
Modbus RTU (RS485 or RS232)
| measure | modbus function | sampling_interval | type | speed | frame | slave | address | cast type |
|---|---|---|---|---|---|---|---|---|
| compartment1_temperature | read input registers | 10 | RS232 | 19200 | 8N1 | 1 | 2048 | uint16 |
| compartment2_temperature | read input registers | 5 | RS485 | 19200 | 8N1 | 1 | 2048 | int16 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
Measure
A unique friendly name of the measurement, e.g. overall_energy_consumption, compartment1_temperature, compartment2_temperature.
Modbus function
Can be one of the following:
read holding registers
read input registers
read holding registers: function 0x03, read input registers: function 0x04.
Sampling interval
The sampling interval in seconds. Minumum is 1, 1Hz.
Target
The target IP in the form of IP:port, e.g. 192.168.0.100:502.
Type
Either RS232 or RS485; RS485 refers to half-duplex.
Speed
Serial speed (in bps) and e.g. 19200, 9600, ...
Frame
Frame format <data_bits><parity><stop_bits>, e.g. 8N1, 8E1, ...
Slave, Address, Size
Modbus parameters to address a specific measurement.
Cast type
Can be one of the following:
| cast_type | size_byte | size_modbus |
|---|---|---|
| uint16 | 2 | 1 |
| uint32 | 4 | 2 |
| int16 | 2 | 1 |
| int32 | 4 | 2 |
| float32 | 4 | 2 |
| float32ByteSwap | 4 | 2 |
| int32ByteSwap | 4 | 2 |
| uint32ByteSwap | 4 | 2 |
All readings should be Bigendian coded. ByteSwap is an exception, where the two Bigendian 16-bit halves are swapped: decoding is implemented as follows for example for float32ByteSwap: B0, B1, B2, B3 are the 4 received octets and float32(B2, B3, B0, B1) is the resulting float32 value.
In case cast type size in bits does not match with the correct amount of bits of the modbus query, then the measurement will not be acquired. As an example, this measure will not be acquired because the query return 16 bit, while casting requires 32 bit:
compartment1_temperature | read input registers | 10 | 192.168.0.100:502 | 1 | 2048 | uint32
Recommended metadata
For each measure specification, it is recommended to also include:
- Measuring unit: preferably expressed using the International System of Units (SI)
- Multiplier: factor applied to the raw Modbus value to obtain the actual measurement. For example, if the multiplier is
0.1and the raw value is123, the resulting value is12.3