03-19-2019 10:09 PM
I understand the defined difference between Input Registers (read only) and Holding Registers (R/W). However, I've got some code that has been working with a number of Modbus devices which looks a bit odd to me. In this code, there are channels that can be written to and then read back into LabVIEW to verify them, or in case the slave device changes the value by itself. Well, they are written to as Holding Registers, logically enough, but the VI that does the reading (using the exact same register addresses) uses the Read Input Registers call.
So my question is: does it make sense that this software seems to have been working up until now? E.g. are there instruments that, as Modbus slaves, will respond to a Read Input Register OR a Read Holding Register command for the very same register? The reason I found this is because I now have an Omega CN740 temperature controller which gave an error when reading a Holding Register using the Read Input Register command. So at least some instruments are picky about what you call a register.
It would make complete sense that you could not write to an Input Register. But how forgiving are most Modbus instruments when reading from a register with the "wrong" command?
Thanks in advance,
DaveT
Solved! Go to Solution.
03-20-2019 02:37 AM
Hi,
Yes, you are right that it seems a bit strange. But remember that the ModBus protocol is old. 40 years old !!
The difference in these commands were necessary back in the 80's. Also because of the processing power and memory sizes of today is became obsolete. But still we want everything to be compatible.
Function code 1 and 2 have the same history. Now in most cases you can use 1 or 2 to read status or coils. (bits)
Function 3 and 4 you can read registers (16 bits) in most cases.
The last 10 years I never saw a slave with a different functionality for code 1 and 2 or for code 3 and 4.
But if you have a 20 or 30 year old ModBus device.......
Kees
03-20-2019 03:22 AM
In my opinion that very much depends on the implementation of the Modbus slave side:
By definition Input and Holding Registers are different and independent memory blocks on the Modbus slave side. So in general reading Input Register 1 will yield another value as reading Holding Register 1. It even is possible that reading one of these two registers will yield an error.
Of course it is also possible that the someone implements the Modbus slave server in such a way that Input and Holding Registers are linked to the same memory block. Yet another possibility would be that on the slave side a value change in a holding register gets written back to the corresponding input register as a confirmation.
To sum up: Read the documentation of the instrument you want to connect to and check what is implemented.
Regards, Jens
03-20-2019 09:24 AM
Thanks for both the replies. As always, these forums are a great resource!
02-07-2020 12:55 PM
To build on this:
@JensG69 wrote:
To sum up: Read the documentation of the instrument you want to connect to and check what is implemented.
Example Modbus RTU device: E+E Elektronik, EE872 CO2 sensor, see User Manual section 5.2.2 (Modbus Register Map, page 10).
Read register: function code 0x03 / 0x04
One can read this sensor's registers using either function code 0x03 (read multiple holding registers) or 0x04 (read input registers). It's all in how the Modbus slave server was implemented.