From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I can't read my exact float value in modbus communication

Solved!
Go to solution

hello,

I am using Multi function meter RS485 communication. i can read the floating address. but i can't read full floating address like 128. need full address like 128.23(after point decimals).

In modbus tool kit it able to read full register. but, In labview i not able to read full register. 

0 Kudos
Message 1 of 19
(3,887 Views)

Hi Balaji,

 

what have you tried so far?

Why don't you attach your VI?

Which if the data bytes in your image do you want to convert to float?

Which device are you using?

What does the manual of that device mention about your float value?

 

(Come on: provide some useful information so we will be able to help you…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 19
(3,851 Views)

It could be a decimal separator issue.

If your app is using the comma (,) as a decimal separator... this is a Windows regional setting, but you can forece LabVIEW to ignore the OS settings and use the dot (.)

 

LabVIEW >> Tools >> Options... >> disable the option "use localized decimal point" (second option from the top in the "Front Panel section)


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 3 of 19
(3,842 Views)

The last time I dealt with MODBUS values like this were always sent as an Integer then you had to scale it to a float.

 

For instance if I asked for the voltage on L1 it would return 12823

 

I would then have to take that integer and divide by 100 to get the 128.23

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 19
(3,810 Views)

If the instructions on how to handle the incoming data can't be found in the manual, they probably want you to buy the SDK.  😉

That being said, without showing us the code and without the manual, you're pretty much on your own.  We can't really help much.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 19
(3,793 Views)

IIRC, Modbus doesn't have a specification for floats.

 

So, everybody makes up things.

 

Sometimes, integers needs to be scaled. That's easy, simply divide by x.

 

Sometimes 4 bytes need to be cast into a single. This can be done in quite a few ways. My device used Modican protocol, but other devices have the two addresses switched, but not the byte order, other have both swapped. IIRC, Modicon and Motorola where at least two of the variations.

 

If you have the bytes of the one or two registers, and a known value, I'm sure we can figure it out.

0 Kudos
Message 6 of 19
(3,764 Views)

Thanks for reply,

 

1. I tried to change the data type to float or long.

2. i attached my VI.

3. All 6 values.

4. multi function meter model no RISH LM1360 and Rs485 to Usb converter.

5. default data type float.

0 Kudos
Message 7 of 19
(3,739 Views)

Thanks for reply,

but, no change  same issue.

0 Kudos
Message 8 of 19
(3,734 Views)
Solution
Accepted by Balaji_dm

If you wire a U16 to a double or single, the value simply gets converted. That's might not be what you need. You get bytes that represent a float, but they are communicated as 16 bit numbers (2 bytes).

 

You probably need to combine two U16s, with a Join Number for instance, and then Type Cast it to a single (4 bytes). Bytes might need swapping, the words might need swapping. you might even need to combine 4 U16s to make a double (8 bytes).

 

Changing the type to float does not magically turn a I16\U16 into a float. You need to make that happen.

0 Kudos
Message 9 of 19
(3,726 Views)

@Balaji_dm wrote:

Thanks for reply,

but, no change  same issue.


You didn't attach any example as to what your bytes are and what you expect the result to be!

0 Kudos
Message 10 of 19
(3,704 Views)