11-01-2019 08:36 AM
thanks for the reply,
Is their any possibility to give any example.
11-01-2019 09:13 AM
What?
YOU need to give the example. What are the values of the bytes you actually read? What is the value you are expecting when you read those registers?
11-01-2019 09:33 AM
wiebe@CARYA wrote:
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.
Here's an example of what wiebe is saying
In one of my programs I am reading 12 watt meters connected through MODBUS.
Here is whats inside my Get_Primary_Measurements VI. (I use the NI-MODBUS library)
Here's the part I want you to see. Each measurement is returned as TWO U16 integers.
I have to combine and convert these to a float. That is what the "Bytes 2 DBL" vi does.
11-01-2019 10:26 AM - edited 11-01-2019 10:27 AM
@RTSLVU wrote:I have to combine and convert these to a float. That is what the "Bytes 2 DBL" vi does.
- Merge the two integers
- Typecast to a SINGLE precision
- Convert to a double precision
But do note that the High Byte and Low Byte might need to be swapped. This depend on the Modbus dialect that is used... Of course you can also swap the read order of the registers.
If that doesn't work (either way), send some data that you read, and the expected value.
11-01-2019 12:34 PM
wiebe@CARYA wrote:But do note that the High Byte and Low Byte might need to be swapped.
Of course you can also swap the read order of the registers.
But can you really do that?
Using the NI-MODBUS library when reading multiple registers you tell it what register to start at and how many to read.
So it always returns the register contents in sequential order starting at the first register.
I guess you could do multiple single register reads to get a different order, but that seems redundant.
11-02-2019 12:38 AM
Thanks for the reply,
What i am getting data is this below pic
What i really need is below pic. This value collected from Modbus toolkit. (value 81.7 is my need)
But, In labview what i getting is 81
11-02-2019 01:08 AM
Thanks for the reply,
Is their any possibility to convert data type has 32 bit float(little- endian byte swap).
11-02-2019 09:33 AM
Sorry, but your data doesn't make any sense. Your two pictures seem to have nothing to do with each other.
There is no way you can get from a simple 0 and 64 or 0 and 27 to values like 81.7 and 46.8.
81.7 as a single precision float would show up as 17059 and 26214.
Have your read the manual thoroughly?
11-02-2019 09:39 AM