04-24-2025 07:12 AM
Hi everyone,
I'm working on an application using LabVIEW 2024 with Modbus RTU communication over RS-485, and I'm having trouble reading data from a signal transmitter (indicator).
Current setup:
I'm using a simple Modbus master-slave configuration just to try to read values.
I'm still trying to fully understand the device’s protocol, so I might be misinterpreting something.
Transmitter configuration:
Baud rate: 9600
Data bits: 8
Stop bit: 1
Parity: None
Scan rate: 0
Sent rate: 0
Communication module: Modbus RTU
Unit ID (slave address): 1
Scale: 0
The issue:
I'm not able to read the indicator values properly. Communication seems to be happening, but the data I receive doesn't make sense (or I just get zero). I suspect I might be reading the wrong registers or not interpreting the protocol correctly.
Below, I’m attaching:
The transmitter’s Modbus protocol document
A screenshot of my LabVIEW application
If anyone has experience with this kind of setup or has any tips (especially around correctly reading registers or setting up the communication), I’d really appreciate your help!
Thanks in advance!
Solved! Go to Solution.
04-24-2025 08:20 AM
I just took a brief look at the VI you attacked and at least two things stood out (no guarantee that there are not other things);
First off you try to write two doubles to holding holding register 0, which in this case means registers 40001-40006 in the supplier's specification, which are defined as read only...So you probably get an error back on that, which affects the next step where you try to read 6 registers from 40036, which you for some reason interpret into a 9-element (!) cluster of U16's which does not make sense as they come in as 6 U16s already and you can just use array index to get to the U16 you try to display.
Strip away the write, skip the loop and set the read to address 0 and the number of holding registers to e.g. 1 and just see if that returns something (display the error cluster in the loop to see any errors as they come). Tell us what it says if you want further support...
If that returns OK you can start to add more and loop things. Use a third party master to verify that you should be able to do this with your software (make sure you close LabVIEW before so the serial port is not blocked...), and if needed compare the poll command sent on the serial port form that software with the one you generate (if any) with your LabVIEW code...Once they match you can expect your code to work too.
PS. I have never used the NI library for Modbus (we write our own instead to have more low level control) so I may have overlooked other things here...If you want to try a nice alternative here is one with quite a nice design:
https://www.vipm.io/package/mb_master/
04-24-2025 12:09 PM - edited 04-24-2025 12:28 PM
Alright, so I tried to keep things as simple as possible and I managed to get valid results — values are displaying correctly on the indicator now. When the value is negative, it shows up as 65535, which I assume is due to unsigned interpretation — but that basically solves my issue for now!
At this point, it's mostly about adjusting the zero offset on the physical device, but for testing purposes, it’s good enough and I can finally start doing at least a very basic analysis.
Here’s what I ended up using:
- Starting address: 0
- Number of inputs: 1
(I might try to convert this into a continuous array later, but I think I can figure that part out — or I’ll just be back here asking for help again 😄)
Thanks again!
PS. I forget to add the .vi, sorry
04-24-2025 12:55 PM
Hi,
Reading address 40001 is a DCS notation in my world.
For the actual ModBus usage this address 0000 using function code 3 (or 4)
This may look strange but connecting DCS to a ModBus slave this normal practice.
Kees
04-29-2025 01:18 PM
Okay, so I don't know what to do. For some reason, now it just shows this error no matter what.
Maybe it's the driver, I just don't know. I tried uninstalling everything and reinstalling it, but in the end, nothing changed — and I just don't know what else I can do.
04-29-2025 01:49 PM
This is not a ModBus problem. ;Your serial link is not working.
RS-485 is a very good interface if it is setup correctly.
Can you show me the connection. How long are the wires between the device and the computer.
Have you tried to swap the A and B (or + and -) wire ?
Some manufacturers use notations as A- and B+. Very confusing.
Kees
04-29-2025 02:25 PM
This seems like a TCP terror, have you accidently changed the type from serial RTU to Modbus TCP?
04-30-2025 06:05 AM
Alright, I'm going to post everything I can to try to figure out this issue:
I'm using the same settings that were already working last week.
[Image of the HK]
This one is using Modbus Test Master.
[Image of the Master]
Now, regarding the question about the wiring — I wasn’t the one who set it up, but according to my colleague, he hasn’t touched the cables since the first installation.
[Photo of the RS485 wiring]
[Photo of the device]
04-30-2025 11:45 AM - edited 04-30-2025 11:50 AM
There was a broken wire in the RS485 connection.
After fixing it, everything is working properly now. Thanks for the help!
The only issue now is with negative numbers — for some reason, it's showing 65554, and I don’t know why.
05-01-2025 12:41 AM
65554 is larger than 16 bits.
If it is 65535 than it could also be -1
Depends on the number format.
Kees