LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RTU Reading Issue with LabVIEW 2024

Solved!
Go to solution

@K C  escreveu:

65554 is larger than 16 bits.

 

If it is 65535 than it could also be -1

Depends on the number format.

 

Kees


65504 = -33
65502 = -35
65512 = -24

Yes, yes — if what I wrote down isn't wrong, the values I'm seeing are pretty close to the ones you listed above.

Right now, I'm trying to apply a filter where I take the unique value from the array, and if that value is less than zero, I set it to 0. Then I convert it back into an array so it can be processed later.

But I’m having some trouble with this. Could you take a look and tell me what I might be doing wrong?

After that, I still need to figure out how to display the values properly — since it's in an array, it's not very easy to interpret as-is. I’m thinking that maybe if I handle the data individually first, and only reassemble it into an array afterwards, it might be easier to manage and visualize.

I also have to be careful with the data type — apparently it's sending the data as U16, but I was interpreting it as I16, while what I probably need is DBL.

0 Kudos
Message 11 of 15
(444 Views)

The Modbus protocol only knows u16 registers, which is why the driver has a u16 output. Whether that is the correct datatype depends on the device that sends it. You have to convert it to the correct type yourself. Use the Numeric>>Conversion palette or Type Cast from Numeric>>Data Manipulation.

It is an array because you can potentially read more than one register at a time. If you read one register, you get a one-element array. You can just index it.

Is this what you are trying to do?

snip.png

0 Kudos
Message 12 of 15
(431 Views)

It's more or less this 

MarcusP_0-1746188455561.png

I'm trying to filter the values, and if they are above 65000 — it's just because, as was mentioned, 65535 could actually be -1, so this was the best workaround I could think of for now.

Then, if the value is negative, I clamp it to 0. After that, I rebuild the array.
To be honest, I'm not really sure if this is the correct way to do it.

0 Kudos
Message 13 of 15
(425 Views)

Maybe you tell more about the device that are reading.

btw. if the value is a I16 numbers above 32767 are negative.

Do you have more information about your ModBus device or post the manual here.

 

Kees 

0 Kudos
Message 14 of 15
(310 Views)

Hi Kees,

Thanks for your help! I was able to solve the problem — it turned out to be a loose wire, which has already been fixed.

Right now, when the reader receives the value, it's converted to I16. If the value is negative, I set it to 0. Then I convert the data from Newtons (N) to metric tons (tf), generate a new array, and pass it through a shift register to build the final array.

Thanks again for your support — it really helped me get through this!

Best regards,

Marcus

0 Kudos
Message 15 of 15
(296 Views)