32-Bit floating point
32-bit floating point values use 2 registers each. This is the default FLOAT data type in Campbell
Scientific data loggers. Select the appropriate
ModbusOption
to avoid post-processing.
15.2.8 Modbus tips and troubleshooting
Most of the difficulties with Modbus communications arise from deviations from the standards,
which are not enforced within Modbus. Whether you are connecting via Modbus to a solar
inverter, power meter, or flow meter, the information provided here can help you overcome the
challenges, and successfully gather data into a Campbell data logger. Further information on
Modbus can be found at:
l
l
l
www.lammertbies.nl/comm/info/modbus.html
15.2.8.1 Error codes
Modbus defines several error codes, which are reported back to a master from a slave.
ModbusMaster()
displays these codes as a negative number. A positive result code indicates
no response was received.
Result code -01: illegal function
The illegal function error is reported back by a Modbus slave when either it does not support the
function at all, or does not support that function code on the requested registers. Different
devices support different functions (consult the device documentation). If the function code is
supported, make sure you are not trying to write to a register labeled as read-only. It is common
for devices to have holding registers where read-only and read/write registers are mapped next to
each other.
An uncommon cause for the -01 result is a device with an incomplete implementation of
Modbus. Some devices do not fully implement parsing Modbus commands. Instead, they are
hardcoded to respond to certain Modbus messages. The result is that the device will report an
error when you try selectively polling registers. Try requesting all of the registers together.
Result code -02: illegal data address
The illegal data address error occurs if the slave rejects the combination of starting register and
length used. One possibility, is a mistake in your program on the starting register number. Refer
to the earlier section about register number and consult the device documentation for support
information. Also, too long of a length can trigger this error. The
ModbusMaster()
instruction
15. Communications protocols
95