08-01-2019 09:27 AM - edited 08-01-2019 09:41 AM
Hello all,
I have never used modbus protocol before and I am trying to get data from a 3rd party sensor in our facility using Modbus TCP. I have installed the NI Modbus Library v1.2.1.42 using the VI package manager. It looks like I am able to connect, however I can't seem to get the data.
I received some general instructions from the company who monitors these sensors that contains the IP address and the register of the sensors.
I was able to connect with the provided example in the modbus library but it errored out with any command I gave it. I tried to create my own basic VI to pull the data with no luck (see attached snippet). I incremented/decremented the register number by 1 to see if there was an offset (i read that somewhere) and that did not help.
To be honest, I'm not sure if the "read holdings register" is the appropriate VI to use, it just seemed the most logical as I don't want to write anything. Any advice would be much appreciated.
Thanks
Solved! Go to Solution.
08-01-2019 12:43 PM
I figured it out with some help from other threads.
This was a good reference:
I was close on my first attempt, just needed to omit the leading 4 from the register input. It also defaults to the first device/unit so I had to specify I wanted the 5th unit/device. Also no idea why the help menu of the "Set unit ID" VI says it won't work for TCP, because it does work and you have to use it if you have multiple devices.
08-01-2019 01:01 PM
@DP2018 wrote:
I. Also no idea why the help menu of the "Set unit ID" VI says it won't work for TCP, because it does work and you have to use it if you have multiple devices.
Yes, Set Unit ID definitely works and may be needed for TCP/IP. I think it is a documentation error. I think someone thought that Unit ID isn't needed because the IP address helps identify the device. However, certain devices definitely need a unit ID. For example, a remote serial server working off of ethernet. There is one ethernet port to the device and it has an IP, but if it has multiple serial ports on it, you need the unit ID to know which serial port it is talking to!